167 Commits

Author SHA1 Message Date
Massimiliano Pinto
775b318889 Added constants to gw_decode_mysql_server_handshake
Check status of gw_read_backend_handshake and gw_send_authentication_to_backend in gw_read_backend_event
2013-09-12 16:08:31 +02:00
vraatikka
6813f760a5 Fix for bug #205 - http://bugs.skysql.com/show_bug.cgi?id=205 . In gw_read_backend_event, read client_protocol by using dcb->session->client pointer but only after it is sure that there is something to write to client. This doesn't ensure that client pointer in session is valid, but it should be.
Return value of dcb_read is checked and buffer pointer is not used if nothing was read.
2013-09-09 15:00:37 +03:00
vraatikka
66e9be814b dcb.h
-------
Removed DCB states DCB_STATE_IDLE, and DCB_STATE_PROCESSING.
Added DCB_STATE_UNDEFINED for initial content for state variable which doesn't have any specific value set, and DCB_STATE_NOPOLLING to indicate that dcb has been removed from poll set.

Added following dcb roles: DCB_ROLE_SERVICE_LISTENER for listeners of services, and DCB_ROLE_REQUEST_HANDLER for client/backend dcbs. Listeners may have state DCB_STATE_LISTENING, but not DCB_STATE_POLLING. Request handlers may have DCB_STATE_POLLING but not DCB_STATE_LISTENING. Role is passed as an argument to dcb.c:dcb_alloc.

From now on, struct check numbers of DCB are included and checked in DEBUG build only.

Added dcb_role_t dcb_role-member to DCB as well as SPINLOCK dcb_initlock, which protects state changes.

Removed extern keyword from function declarations because functions are by default externally visible if they are declared in header.

dcb.b
------
Function dcb_set_state, and dcb_set_state_nomutex provide functions for changing dcb states. Latter implements a state machine for dcb.
Function dcb_add_to_zombieslist replaces dcb_free. It adds in atomic step dcb to zombieslist and changes state to DCB_STATE_ZOMBIE.
Function dcb_final_free removes dcb from allDCBs list, terminates router and client sessions, and frees dcb and related memory.
Function dcb_process_zombies removes executing thread from dcb's bitmask, and it there are no further thread bits, moves dcb to a victim list, and finally, for each dcb on victim list, closes fd and sets state to DCB_STATE_DISCONNECTED.
Function dcb_close sets dcb state to DCB_STATE_NOPOLLIN, removes dcb from poll set and sets bit to bitmask for each server thread in an atomic step.  

poll.c
------
Function poll_add_dcb sets either DCB_STATE_LISTENING or DCB_STATE_POLLING state for newly created dcb, depending whether the role of dcb is DCB_ROLE_SERVICE_LISTENER, or DCB_ROLE_REQUEST_HANDLER, respectively. Then dcb is set to poll set.

poll_waitevents : commented out code which skipped event if dcb was added to zombieslist or if fd was closed. Added state checks.

service.c : Minor changes.
httpd.c : Removed dcb state changes. They are done in core.
mysql_backend.c : Added checks, removed dcb state changes.
mysql_client.c : Removed dcb state changes. Added checks.
mysql_common.c : Minor changes
telnetd.c : Removed state changes. Replaced some typecasts and pointer references with local variable reads.
skygw_debug.h : Removed two states, and added two to state printing macro.
2013-09-05 22:00:02 +03:00
Massimiliano Pinto
b01cf2365e Added log error or ss_dassert instead of silent returning 2013-09-04 15:31:04 +02:00
Massimiliano Pinto
61df7eb07d Added checks against NULL in gw_read_backend_event for dcb->session and dcb->session->client 2013-09-04 10:57:08 +02:00
vraatikka
9df2040a8a Removed unused variables, changed call to mysql_protocol_init to reflect new prototype. 2013-09-01 00:32:57 +03:00
vraatikka
3dff91e80f In gw_create_backend_connection, replaced inlined protocol init with call to mysql_protocol_init (mysql_common.c). Replaced fprintfs with logging commands. 2013-08-31 23:51:54 +03:00
Mark Riddoch
a445b6ff37 Fixes for NULL test for function returns such as malloc() - as reported by Coverity 2013-08-29 13:34:21 +02:00
vraatikka
527df6c7f3 Merge, mostly. 2013-08-28 23:26:09 +03:00
Massimiliano Pinto
ff109c6319 dcb->state set wheere missing or changed 2013-08-27 10:52:43 +02:00
vraatikka
df5f2f29b2 Removed undefined function declaration. Added trace and error log. 2013-08-23 23:25:12 +03:00
vraatikka
68a5a389ee Removed SS_DEBUG macros around necessary include directives. 2013-08-23 13:42:10 +03:00
vraatikka
0401290021 Added spinlock ses_lock to struct SESSION to ensure that for each session closeSession is called only once.
closeSession is called from mysql_backend.c:gw_read_backend_event, and from dcb.c:dcb_close.

This is part of Bug #163.
2013-08-22 10:42:18 +03:00
vraatikka
ea79b38e4f Check return value of dcb_read and if it failed, don't access head of linked list. 2013-08-19 19:39:47 +03:00
Massimiliano Pinto
75e7de182f fprintf debug for added backend connection is protected by if (backend->fd > 0) 2013-08-07 09:39:29 +02:00
vraatikka
cae4d38a7e Removed unnecessary argument from log manager commands because it is not used and it is always NULL. 2013-08-04 23:30:47 +03:00
Timofey Turenko
a7c82310f9 moving files to /server to make merge possible 2013-07-28 05:31:11 +00:00