dcb_write earlier returned an error (== 0) if errno was not set and other conditions were satisfied. In practice, if write was done in write queue, queue pointer was not updated and dcb_write returned and error. Changed the error detection condition so that it requires errno being set, at least.
readwritesplit.c
Clean up.
Removed embedded server startup parameter '--skip-innodb' and replaced TRUE, and FALSE with true and false, respectively.
gateway.c
Removed embedded server startup parameter '--skip-innodb' because libmysqld inside MariaDB 5.5.33 + doesn't start with that paramter.
mysql_client.c:gw_MySQLWrite_client is simply return dcb_write(dcb, queue);
The return codes are not the same of the code replaced, but they are not checked in the caller routines.
dcb_write, if write failed, gwbuf wasn't freed.
mysql_backend.c
gw_MySQLWrite_backend, if dcb wasn'r in POLLING state then write was skpiped but gwbuf wasn't freed.
mysql_client.c
gw_MySQLWrite_client, disabled the use of dcb_write because it returns different values than the code it replaced. Also removed erroneous call of gwbuf_consume.
mysql_common.c
mysql_send_custom_error, removed erroneous call of gwbuf_free.
blockbuf_get_writepos, when all existing buffers in blockbuf list are full, a new block buffer is created and added to the list. Adding to the list is done with mutex on hold. Mutex shouldn't be freed before the next iteration in while loop, which expects that bblist mutex is on hold. At the end of the function, removed an unnecessary debug assertion.
testlog.c
Enabled more intensive write test. Replaced TRUE and FALSE with true, false, respectively.
skygw_utils.cc
simple_mutex_unlock, added debug assertion to ensure that pthread mutex's user counter is always at least 0 (it goes negative in double free).
changed gw_receive_backend_auth declaration to return int instead of boolean.
mysql_backend.c:
gw_read_backend_event calls gw_receive_backend_auth which either fails (== -1), succeeds with nothing to read (== 0) or succeeds (== 1). For each case there is handling. If dcb_read succeeds without read bytes, return asap.
mysql_client.c:
gw_error_client_event, gw_client_close, gw_client_hangup_event : all close client dcb but now they also close backend dcb.
mysql_common.c:
gw_receive_backend_auth, return -1, 0, or 1 if read from backend failed, was empty, or succeed, respectively.:
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.:
tuned error printing and log writing output format
dcb.c :
dcb_connect, check return value of poll_add_dcb and behave accordingly.
dcb_write, in case of SIFPIPE, only write to trace log.
dcb_close, dassert with incorrect dcb states.
gateway.c :
added file_write_header to print header similar than in logs to stderr.
main, add signal handler for SIGPIPE
poll.c :
poll_remove_dcb, don't fail if dcb is in NOPOLLING or in ZOMBIE states.
poll_waitevents, write EPOLLHUPs to trace log, don't even attempt to write to closed socket.
readconnection.h :
shortened comment.
readwritesplit.h :
replaced generic names with more specific ones.
httpd.c :
Check listen return value and behave accordingly.
mysql_backend.c :
Tiny clean up.
mysql_client.c :
gw_MySQLListener, Check listen return value and behave accordingly.
mysql_common.c :
Shortened a header.
telnetd.c :
telnetd_listen, check listen return value and behave accordingly.
readconnroute.c :
Tuned log writing format.
readwritesplit.c :
Added function search_backend_servers, which chooses suitable backend and master server among those known by Maxscale. Fixed clean-up routines. Not ready yet but works somehow.
testroute.c :
Cleanup.
skygw_utils.cc :
Log writing clean up.
- Checked argument types and counts
- Removed trailing line feeds
- Removed thread ids from error logs (they are used in trace / debug log
- Added some state information to dcbs
- Added prefix 'Error' or 'Fatal' to error logs.
- Switches all error logs to use flushing log write.
Reproduce #217 by connecting with telnet to debug client interface and execute command:
fail accept 23
and try to execute read query, for example, with
mysql -h 127.0.0.1 -P 4008 -u maxuser -pmaxpwd -e 'select current_user(), @@server_id'
dcb_final_free: Router session is not closed anymore when dcb is closed. Router session is shared among all dcbs and is closed and freed with session.
dcb_connect: dcb's state must be switched fro DCB_STATE_ALLOC to DCB_STATE_DISCONNECTED before dcb_final_free can be called for it.
dcb_close: poll_remove_dcb encapsulates dcb's state transition in the same way as poll_add_dcb. Removed state modification from dcb_close. Read return value of poll_remove_dcb and log accordingly.
dcb_set state: remove dassert if dcb_set_state_nomutex returned false. False can be returned indicating that intented change didn't occur but the end state, for example, may be acceptable. Failures in state transitions are asserted in dcb_Set_state_nomutex.
poll.c
poll_add_dcb: dcb state is now set here to either DCB_STATE_LISTENING or to DCB_STATE_POLLING according to dcb's role. Failures in state setting and in epoll_ctl are detected, logged and handled.
poll_remove_dcb: Failures in state setting and epoll_ctl are detected, logged, and handled.
mysql_client_server_protocol.h
Removed macros MYSQL_FAILED_AUTHENTICATION & MYSQL_SUCCESFUL_AUTHENTICATION as they were not necessary and used with constant values 0 and 1 depending on the case.
Renamed variable 'conn' to 'protocol' in cases where it meant protocol.
mysql_backend.c
gw_read_backend_event: In case when there was nothing to read or read failed, backend dcb is closed because situation is assumed to be such that backend server closed its side of the socket. Removed macros MYSQL_FAILED/SUCCESFUL_AUTHENTICATION
gw_create_backend_connection: Assigned protocol with fd which is connected to backend.
backend_write_delayqueue: In case where dcb_write fails to write anything, close backend dcb to avoid it getting hanging.
mysql_client.c
gw_read_client_event: Read return value of routeQuery and if it isn't == 1, call mysql_send_custom_error with client dcb and set client's protocol state to MYSQL_IDLE instead of MYSQL_ROUTING.
gw_MySQLAccept: Static reply counter was erroneously used as a criteria for jumping to return point where return value was constantly 'success' (=0). Replaced static reply counter with private. Fixed return value in different cases.
mysql_common.c
gw_receive_backend_auth: Changed to return boolean values indicating of success or failue. Used integers which were assigned to macroed values on the caller side. Added length check before accessing buffer.
readconnroute.c
Cut too long lines and removed statements with side effects.
skygw_debug.h
Added macro STRPROTOCOLSTATE(s) to produce string representation of a given protocol state.