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:
@ -41,6 +41,8 @@
|
|||||||
* 16/07/2013 Massimiliano Pinto Added command type for dcb
|
* 16/07/2013 Massimiliano Pinto Added command type for dcb
|
||||||
* 23/07/2013 Mark Riddoch Tidy up logging
|
* 23/07/2013 Mark Riddoch Tidy up logging
|
||||||
* 02/09/2013 Massimiliano Pinto Added session refcount
|
* 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
|
* @endverbatim
|
||||||
*/
|
*/
|
||||||
@ -511,7 +513,7 @@ int fd;
|
|||||||
*
|
*
|
||||||
* @param dcb The DCB to read from
|
* @param dcb The DCB to read from
|
||||||
* @param head Pointer to linked list to append data to
|
* @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.
|
* iteration of while loop.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
@ -520,7 +522,7 @@ dcb_read(DCB *dcb, GWBUF **head)
|
|||||||
GWBUF *buffer = NULL;
|
GWBUF *buffer = NULL;
|
||||||
int b;
|
int b;
|
||||||
int rc;
|
int rc;
|
||||||
int n = -1;
|
int n = 0;
|
||||||
int eno = 0;
|
int eno = 0;
|
||||||
|
|
||||||
CHK_DCB(dcb);
|
CHK_DCB(dcb);
|
||||||
@ -549,6 +551,7 @@ int eno = 0;
|
|||||||
}
|
}
|
||||||
/** Nothing to read - leave */
|
/** Nothing to read - leave */
|
||||||
if (b == 0) {
|
if (b == 0) {
|
||||||
|
n = 0;
|
||||||
goto return_n;
|
goto return_n;
|
||||||
}
|
}
|
||||||
bufsize = MIN(b, MAX_BUFFER_SIZE);
|
bufsize = MIN(b, MAX_BUFFER_SIZE);
|
||||||
|
|||||||
@ -40,6 +40,7 @@
|
|||||||
server replies to client via router->clientReply
|
server replies to client via router->clientReply
|
||||||
* 04/09/2013 Massimiliano Pinto Added dcb->session and dcb->session->client checks for NULL
|
* 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
|
* 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 */
|
/* read available backend data */
|
||||||
rc = dcb_read(dcb, &head);
|
rc = dcb_read(dcb, &head);
|
||||||
|
|
||||||
if (rc <= 0) {
|
if (rc < 0) {
|
||||||
/**
|
/**
|
||||||
* Backend generated EPOLLIN event and if there is
|
* Backend generated EPOLLIN event and if backend has failed, connection
|
||||||
* nothing to read or backend failed, connection
|
* must be closed to avoid backend dcb from getting hanged.
|
||||||
* must be closed to avoid backend dcb from getting
|
|
||||||
* hanged.
|
|
||||||
*/
|
*/
|
||||||
(dcb->func).close(dcb);
|
(dcb->func).close(dcb);
|
||||||
rc = 0;
|
rc = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user