4320 Commits

Author SHA1 Message Date
vraatikka
e1d7a5640d Put structure check fields behind SS_DEBUG macros. Thus, they are only included in debug builds. 2013-09-09 10:05:46 +03:00
vraatikka
27338c2537 Merge 2013-09-09 00:05:28 +03:00
vraatikka
d535346987 Removed dead code. 2013-09-08 23:32:13 +03:00
vraatikka
e61c19c6fe Major change. router_session is freed as a last operation before freeing session. Fixes frequently occurring failures when multiple threads are running. 2013-09-08 23:27:57 +03:00
vraatikka
6a07ef8245 Added debug logging to poll_remove_dcb. Removed dead code from poll_waitevents. 2013-09-08 23:26:15 +03:00
vraatikka
03fed73b64 Added missing spinlock_release to dcb_add_to_zombieslist to avoid deadlock. 2013-09-08 23:24:54 +03:00
Mark Riddoch
0d47aa2d3a Remove some contention on the DCB zombie queue spinlock
A fix for final free beign called when a DCB has not yet had a session created
2013-09-05 22:05:55 +02: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
vraatikka
17ec98fa3d session was assigned state SESSION_STATE_READY outside protected block, and backend dcb thread saw authentication data and session in SESSION_STATE_ALLOC state, which trapped. Moved state assignment inside protection block. 2013-09-05 19:47:42 +03:00
vraatikka
4f8057034a Protected temporarily with spinlock gethostbyname which is not thread safe. This should be changed permanently so that gethostbyname is replaced with getaddrinfo. 2013-09-05 19:42:59 +03:00
Massimiliano Pinto
8f98ae4751 Removed old mysql protocol files 2013-09-04 15:53:51 +02:00
Massimiliano Pinto
6888735f7b Removed old gateway_mysql_protocol.c
server/core/Makefile updtated
2013-09-04 15:41:08 +02:00
Mark Riddoch
f74f67540f Added spinlock protection for the session association to the DCB and
reworked the reference count mechanism on the session.  Introduced a
FREE state for the session and alter the session destruction flow so
that we only remove the session when all the DCB's have singled they
have finished processing events for the DCB rather than when the first
thread decides to clsoe the DCB.
2013-09-04 12:24:59 +02:00
Massimiliano Pinto
db164be946 Added spinlock protection for refcount increase in dcb_connect 2013-09-04 10:00:40 +02:00
vraatikka
366441a4bb Added debug assert for checking return value of memory allocation. 2013-09-02 21:53:49 +03:00
vraatikka
c4ce2efd9f Added debug assert for DCB states prior processing. 2013-09-02 21:52:57 +03:00
vraatikka
5487f84532 Added logging to session refcount increment. Some minor improvements. 2013-09-02 21:52:09 +03:00
Massimiliano Pinto
f80bb51db1 dcb_close sets some session fields to NULL:
dcb->session->client = NULL;

dcb->session = NULL;

There is a local copy of dcb->seesion before setting it to NULL
2013-09-02 19:33:55 +02:00
Massimiliano Pinto
31cda5ad65 Added session refcount in session.h
The refcount is incremented in dcb_connect and in mysql_client.c after session_alloc
2013-09-02 10:26:34 +02: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
94a8ad68d3 Checked for bug #178. Added error logs to suitabl places. 2013-08-29 09:50:16 +03:00
vraatikka
48165bf5cd Removed unused protocol_mutex and references to it. 2013-08-28 23:25:27 +03:00
vraatikka
ae9fce8591 Added write and read lock to DCB to protect concurrent threads fro executing EPOLLIN and EPOLLOUT events on same descriptor, respectively. Added consistency checks and trace logging. 2013-08-28 23:09:37 +03:00
vraatikka
9a8e271417 client->data is copied to session->data already in session_alloc to ensure that authentication information is set when background connection is started to establish in concurrent thread. 2013-08-28 23:06:09 +03:00
vraatikka
786468fc5d Added status checks, removed some dead code, changed macros to enumerated types, renamed variables to reflect better what they mean. 2013-08-28 22:59:53 +03:00
vraatikka
6f0ccd7b42 Added static simple_mutex_t epoll_wait_mutex, which is acquired and released in poll_waitevents. 2013-08-23 22:45:06 +03:00
vraatikka
c9ff06e0f5 Increased maximum path length from 180 to 255, and replaced sprintf with snprintf to prevent buffer overflow. 2013-08-23 22:27:40 +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
b18d89300d Bug 179 2013-08-22 00:26:24 +03:00
vraatikka
8dfd5de923 Fix merge 2013-08-22 00:01:44 +03:00
Jan Lindström
b6ba1954f5 Merge 2013-08-19 08:48:33 +03:00
Mark Riddoch
9fe7a83675 Fixes for resource leaks foudn with Coverity.
Bug 173, 174, 175, 176 and 177
2013-08-21 17:26:55 +02:00
vraatikka
21dabda848 Removed redundant log writings. 2013-08-20 10:49:35 +03:00
vraatikka
c5ed473ab7 Check return value of ioctl in dcb_read and act accordingly. 2013-08-19 19:40:51 +03:00
vraatikka
45ea459e20 Check the return value of ioctl in dcb_read. 2013-08-19 17:09:33 +03:00
vraatikka
f750b8545a Merge 2013-08-19 16:40:44 +03:00
vraatikka
c119f7b7b8 In dcb_close read and set dcb->state by holding dcb->writeqlock. This prevents simultaneous calls to closeSession. 2013-08-19 16:38:55 +03:00
Mark Riddoch
b1c398e944 Bug 145 - Silently ignore missing .secrets file 2013-08-19 15:36:26 +02:00
vraatikka
24367fb400 Removed dcb->mutex since it didn't solve any problem. 2013-08-19 13:01:07 +03:00
vraatikka
97b3da1d79 Added simple_mutex_t dcb->mutex to DCB struct to protect processing of single dcb in poll.c:poll_waitevents. This is a coarse locking but seems to work with multiple threads at least with very simple load.
Added trace logging to many locations.
2013-08-16 23:52:10 +03:00
vraatikka
7c0ed171a0 Added trace log to event handling. 2013-08-15 22:45:11 +03:00
vraatikka
a1b05359ac Added trace log where epoll_wait returns and to where read fomr/write to socket decicion is made. 2013-08-15 20:16:23 +03:00
vraatikka
90e6e11923 Added debug trace to socket read. 2013-08-15 11:13:34 +03:00
vraatikka
bed0206895 If config file is specified in command-line argument, then it won't be searched from anywhere else. Earlier command-line argument was ignored if MAXSCALE_HOME was set. 2013-08-14 15:42:35 +03:00
vraatikka
eba81f0501 Corrected comparison between strcmp and 0 so that threads configuration parameter value becomes effective. 2013-08-14 11:25:03 +03:00
vraatikka
249413b2c6 Freed thread structs. 2013-08-12 21:05:44 +03:00
vraatikka
c5fd94590c Freed hashtable iterator to dcb_usersPrint. 2013-08-12 21:04:31 +03:00
vraatikka
64cb6eca56 mysql_library_end is not called if it wasn't initialized properly. 2013-08-12 13:12:23 +03:00
Massimiliano Pinto
8a9d178785 Fixed bug for invalid memory access in row[1]+1 when row[1] is "" 2013-08-08 18:40:02 +02:00
vraatikka
f1498e4403 Added log flusher thread, which flushes once per second. 2013-08-08 00:08:45 +03:00