Removed session->backends

Added dcb->fd in some fprintf debug
This commit is contained in:
Massimiliano Pinto 2013-07-01 17:00:24 +02:00
parent ecf498448c
commit b33b3753dc
3 changed files with 12 additions and 23 deletions

View File

@ -28,7 +28,8 @@
* 12-06-2013 Massimiliano Pinto gw_read_gwbuff
* with error detection
* and its handling
*
* 01-07-2013 Massimiliano Pinto Removed session->backends
from gw_read_gwbuff()
*/
#include <gw.h>
@ -46,7 +47,7 @@ setipaddress(struct in_addr *a, char *p) {
struct hostent *h = gethostbyname(p);
if (h == NULL) {
if ((a->s_addr = inet_addr(p)) == -1) {
error("unknown or invalid address [%s]\n", p);
fprintf(stderr, "unknown or invalid address [%s]\n", p);
}
} else {
memcpy(a, h->h_addr, h->h_length);
@ -86,11 +87,8 @@ int gw_read_gwbuff(DCB *dcb, GWBUF **head, int b) {
int n = -1;
if (b <= 0) {
fprintf(stderr, "||| read_gwbuff called with 0 bytes, closing\n");
if (dcb->session->backends) {
(dcb->session->backends->func).error(dcb->session->backends);
}
dcb->func.error(dcb);
fprintf(stderr, "||| read_gwbuff called with 0 bytes for %i, closing\n", dcb->fd);
dcb->func.close(dcb);
return 1;
}
@ -99,10 +97,7 @@ int gw_read_gwbuff(DCB *dcb, GWBUF **head, int b) {
if ((buffer = gwbuf_alloc(bufsize)) == NULL) {
/* Bad news, we have run out of memory */
/* Error handling */
if (dcb->session->backends) {
(dcb->session->backends->func).error(dcb->session->backends);
}
(dcb->func).error(dcb);
(dcb->func).close(dcb);
return 1;
}
@ -114,10 +109,7 @@ int gw_read_gwbuff(DCB *dcb, GWBUF **head, int b) {
return 1;
} else {
fprintf(stderr, "Client connection %i error: %i, %s\n", dcb->fd, errno, strerror(errno));;
if (dcb->session->backends) {
(dcb->session->backends->func).error(dcb->session->backends);
}
(dcb->func).error(dcb);
(dcb->func).close(dcb);
return 1;
}
}
@ -125,10 +117,7 @@ int gw_read_gwbuff(DCB *dcb, GWBUF **head, int b) {
if (n == 0) {
// socket closed
fprintf(stderr, "Client connection %i closed: %i, %s\n", dcb->fd, errno, strerror(errno));
if (dcb->session->backends) {
(dcb->session->backends->func).error(dcb->session->backends);
}
(dcb->func).error(dcb);
(dcb->func).close(dcb);
return 1;
}

View File

@ -28,6 +28,8 @@
* 01-06-2013 Mark Riddoch Initial implementation
* 14-06-2013 Massimiliano Pinto Added void *data to session
* for session specific data
* 01-07-2013 Massimiliano Pinto Removed backends pointer
from struct session
* @endverbatim
*/
#include <time.h>

View File

@ -781,7 +781,7 @@ int gw_read_client_event(DCB* dcb) {
}
if (ioctl(dcb->fd, FIONREAD, &b)) {
fprintf(stderr, "Client Ioctl FIONREAD error %i, %s\n", errno , strerror(errno));
fprintf(stderr, "Client Ioctl FIONREAD error for %i: errno %i, %s\n", dcb->fd, errno , strerror(errno));
return 1;
} else {
//fprintf(stderr, "Client IOCTL FIONREAD bytes to read = %i\n", b);
@ -1145,9 +1145,7 @@ int gw_MySQLAccept(DCB *listener) {
/*
*/
static int gw_error_client_event(DCB *dcb) {
fprintf(stderr, "#### Handle error function gw_error_client_event, for [%i] is [%s]\n", dcb->state, gw_dcb_state2string(dcb->state));
fprintf(stderr, "#### Handle error function RETURN for [%i] is [%s]\n", dcb->state, gw_dcb_state2string(dcb->state));
fprintf(stderr, "#### Handle error function gw_error_client_event, for [%i] is [%s]\n", dcb->fd, gw_dcb_state2string(dcb->state));
return 1;
}