log_manager.cc:
State update for filewriter was missing and that caused Maxscale to fail if opening of any log file failed. dcb.c: Added EAGAIN and EWOULDBLOCK handling to dcb_read. If dcb_close is called for freshly created dcb, dcb is only freed. gateway.c: Added file_write_footer and write_footer of which the latter is called at exit time. It simply draws a line to screen. gw_utils.c: Some macros for helping comparison between gw_read_gwbuff and dcb_read, which overlap. poll.c: Some macros to help enable/disable mutexing in poll_waitevents service.c: Check return value of listen and session_alloc and behave accordingly. mysql_client.c: If ioctl returned successfully with b==0 it earlier caused closing the client and backend dcbs. Since that doesn't reliably indicate that client has closed socket on its side, Maxscale doesn't close its sockets either. mysql_common.c: In gw_receive_backend_auth, if dcb_read returns n==0, it is not considered as an error anymore. The implemented behavior is not yet complete and correct. Result should be successful but the protocol state shouldn't change to MYSQL_IDLE before backend return is received. In gw_send_authentication_to_backend protocol state was always set to MYSQL_AUTH_RECV even if gw_rwite had failed. Now, return value is read and state is set in caller's context basen on the return value. skygw_utils.cc: Removed ss_dassert from skyge_file_init because it prevented from returning meaningful error meassage to the client.:
This commit is contained in:
@ -521,7 +521,7 @@ int gw_read_client_event(DCB* dcb) {
|
||||
/**
|
||||
* Check how many bytes are readable in dcb->fd.
|
||||
*/
|
||||
if (ioctl(dcb->fd, FIONREAD, &b)) {
|
||||
if (ioctl(dcb->fd, FIONREAD, &b) != 0) {
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
skygw_log_write(
|
||||
@ -538,9 +538,13 @@ int gw_read_client_event(DCB* dcb) {
|
||||
}
|
||||
|
||||
/**
|
||||
* The client socket was closed.
|
||||
* Note that earlier b==0 was translated to closed client socket.
|
||||
* It may, however, happen in other cases too. Besides, if socket
|
||||
* was closed, next write will tell, thus, with b==0 routine can
|
||||
* simply return.
|
||||
*/
|
||||
if (b == 0) {
|
||||
#if 0
|
||||
if (b == 0) {
|
||||
skygw_log_write(
|
||||
LOGFILE_TRACE,
|
||||
"%lu [gw_read_client_event] Dcb %p fd %d was closed. "
|
||||
@ -568,7 +572,12 @@ int gw_read_client_event(DCB* dcb) {
|
||||
|
||||
goto return_rc;
|
||||
}
|
||||
|
||||
#else
|
||||
if (b == 0) {
|
||||
rc = 0;
|
||||
goto return_rc;
|
||||
}
|
||||
#endif
|
||||
switch (protocol->state) {
|
||||
case MYSQL_AUTH_SENT:
|
||||
/*
|
||||
@ -594,7 +603,6 @@ int gw_read_client_event(DCB* dcb) {
|
||||
// example with consume, assuming one buffer only ...
|
||||
queue = gw_buffer;
|
||||
len = GWBUF_LENGTH(queue);
|
||||
//fprintf(stderr, "<<< Reading from Client %i bytes: [%s]\n", len, GWBUF_DATA(queue));
|
||||
auth_val = gw_mysql_do_authentication(dcb, queue);
|
||||
// Data handled withot the dcb->func.write
|
||||
// so consume it now
|
||||
@ -690,7 +698,6 @@ int gw_read_client_event(DCB* dcb) {
|
||||
"client dcb %p.",
|
||||
pthread_self(),
|
||||
dcb);
|
||||
|
||||
(dcb->func).close(dcb);
|
||||
} else {
|
||||
/* Send a custom error as MySQL command reply */
|
||||
@ -724,7 +731,9 @@ int gw_read_client_event(DCB* dcb) {
|
||||
else
|
||||
{
|
||||
/** Route other commands to backend */
|
||||
rc = router->routeQuery(router_instance, rsession, queue);
|
||||
rc = router->routeQuery(router_instance,
|
||||
rsession,
|
||||
queue);
|
||||
/** succeed */
|
||||
if (rc == 1) {
|
||||
rc = 0; /**< here '0' means success */
|
||||
@ -1068,7 +1077,6 @@ int gw_MySQLAccept(DCB *listener)
|
||||
if (protocol == NULL) {
|
||||
/** delete client_dcb */
|
||||
dcb_close(client_dcb);
|
||||
|
||||
skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"%lu [gw_MySQLAccept] Failed to create "
|
||||
@ -1093,6 +1101,13 @@ int gw_MySQLAccept(DCB *listener)
|
||||
*/
|
||||
if (poll_add_dcb(client_dcb) == -1)
|
||||
{
|
||||
/* Send a custom error as MySQL command reply */
|
||||
mysql_send_custom_error(
|
||||
client_dcb,
|
||||
1,
|
||||
0,
|
||||
"MaxScale internal error.");
|
||||
|
||||
/** delete client_dcb */
|
||||
dcb_close(client_dcb);
|
||||
|
||||
@ -1161,7 +1176,6 @@ gw_client_close(DCB *dcb)
|
||||
CHK_PROTOCOL(protocol);
|
||||
}
|
||||
#endif
|
||||
|
||||
dcb_close(dcb);
|
||||
return 1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user