Modified dcb_read return: n = 0 means 0 bytes read without errors

if (rc < 0) is now used testing dcb_read() return, instead of if (rc <= 0)
This commit is contained in:
Massimiliano Pinto 2013-09-27 19:24:23 +02:00
parent e03d2b3ffe
commit c48dd6028f
2 changed files with 9 additions and 7 deletions

View File

@ -41,6 +41,8 @@
* 16/07/2013 Massimiliano Pinto Added command type for dcb
* 23/07/2013 Mark Riddoch Tidy up logging
* 02/09/2013 Massimiliano Pinto Added session refcount
* 27/09/2013 Massimiliano Pinto dcb_read returns 0 if ioctl returns no error and 0 bytes to read
* This fixes a bug with many reads from backend
*
* @endverbatim
*/
@ -511,7 +513,7 @@ int fd;
*
* @param dcb The DCB to read from
* @param head Pointer to linked list to append data to
* @return -1 on error, otherwise the number of read bytes on the last
* @return -1 on error, otherwise the number of read bytes on the last. 0 is returned if no data available.
* iteration of while loop.
*/
int
@ -520,7 +522,7 @@ dcb_read(DCB *dcb, GWBUF **head)
GWBUF *buffer = NULL;
int b;
int rc;
int n = -1;
int n = 0;
int eno = 0;
CHK_DCB(dcb);
@ -549,6 +551,7 @@ int eno = 0;
}
/** Nothing to read - leave */
if (b == 0) {
n = 0;
goto return_n;
}
bufsize = MIN(b, MAX_BUFFER_SIZE);

View File

@ -40,6 +40,7 @@
server replies to client via router->clientReply
* 04/09/2013 Massimiliano Pinto Added dcb->session and dcb->session->client checks for NULL
* 12/09/2013 Massimiliano Pinto Added checks in gw_read_backend_event() for gw_read_backend_handshake
* 27/09/2013 Massimiliano Pinto Changed in gw_read_backend_event the check for dcb_read(), now is if rc < 0
*
*/
@ -312,12 +313,10 @@ static int gw_read_backend_event(DCB *dcb) {
/* read available backend data */
rc = dcb_read(dcb, &head);
if (rc <= 0) {
if (rc < 0) {
/**
* Backend generated EPOLLIN event and if there is
* nothing to read or backend failed, connection
* must be closed to avoid backend dcb from getting
* hanged.
* Backend generated EPOLLIN event and if backend has failed, connection
* must be closed to avoid backend dcb from getting hanged.
*/
(dcb->func).close(dcb);
rc = 0;