e03d2b3ffeIn gw_read_client_event, if ioctl returns non-zero and 'b' (number of readable bytes) is zero, that indicates that socket is closed. Thus, read is now skipped and dcb closed if it is in DSC_STATE_POLLING state.
vraatikka
2013-09-27 14:57:53 +03:00
1120ae9b2cZombie processing had an risk of getting into an infinite loop.
vraatikka
2013-09-27 11:20:28 +03:00
46c5564313Removed states MYSQL_WAITING_RESULT and MYSQL_ROUTING
Massimiliano Pinto
2013-09-26 18:01:48 +02:00
ee7b799bf1Bug 160 - fixed memory leaks with telnetd and debug CLI
Mark Riddoch
2013-09-26 17:38:35 +02:00
1e83308cd1Bug 133 - cleanup data<pid> directory on SIGINT
Mark Riddoch
2013-09-26 16:33:16 +02:00
ab731274fdBug 218 - add error message if MAXSCALE_HOME does not exist
Mark Riddoch
2013-09-26 13:46:04 +02:00
c26bd04ea7Addition of messages to standard error if MaxScale refuses to start for some reason
Mark Riddoch
2013-09-26 12:21:45 +02:00
c1c7a3fb02Additional check for service starts
Mark Riddoch
2013-09-26 10:38:31 +02:00
fe7d0477baImproved configuration object checking
Mark Riddoch
2013-09-26 10:37:55 +02:00
947fc3509bMake configuration file reading more robust
Mark Riddoch
2013-09-25 17:50:12 +02:00
5d22884a9bFixed NULL pointer issue
Mark Riddoch
2013-09-25 16:36:54 +01:00
3b647e47abWhen there is no load but there are zombies to be cleaned up, it used to take at least nthreads*timeout time to get socket closed. Now in this case, once the timeout exceeds for the first time, all threads are allowed to call dcb_process_zombies without having to wait the timeout period until there are no zombies anymore.
vraatikka
2013-09-25 09:12:18 +03:00
20c4a60f01Maxscale doesn't assert if tested with different errors in gw_MySQLAccept.
vraatikka
2013-09-24 16:09:11 +03:00
09cc20b7beImproved behavior of debug cli API command 'fail accept'. It takes now _two_ arguments, Syntax:
vraatikka
2013-09-24 15:48:59 +03:00
3e1322034dAdded logging and som checks.
vraatikka
2013-09-24 15:13:25 +03:00
a7c3cd5f30Related to bug #217, added command 'fail accept <errno>' to debug client's commands. Reproduce #217 by connecting with telnet to debug client interface and execute command:
vraatikka
2013-09-24 15:04:12 +03:00
eec0b74191dcb_printf(pdcb, "\tQueued write data: %d\n", gwbuf_length(dcb->writeq)); is now protected by if (dcb->writeq)
Massimiliano Pinto
2013-09-20 17:53:15 +02:00
302090a168Removed unused local variable.
vraatikka
2013-09-20 15:03:20 +03:00
74aa3638f9dcb.c 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.
vraatikka
2013-09-20 14:32:28 +03:00
85ac4d78ddHTTPD is now working:
Massimiliano Pinto
2013-09-19 12:23:17 +02:00
c7b052aab3Addition of CheckSessions debug entry point
Mark Riddoch
2013-09-18 19:06:32 +02:00
ace4252832Added closeSession to gw_error_backend_event: the backend failure is handled without faults
Massimiliano Pinto
2013-09-18 11:50:19 +02:00
4321861ed8dcb_read : removed redundant or dead code. dcb_write: if fail backendfd | clientfd is used, now listener operations don't cause failure.
vraatikka
2013-09-17 21:54:38 +03:00
4cf5b3293fAdded check routine for gw_buffer. Only effective in debug build.
vraatikka
2013-09-17 15:10:16 +03:00
8bf73ea154Replaced write system function with wrapper gw_write. It allows for generating failures by using telnet commands, fail backendfd, fail clientfd, which are available in debug build only.
vraatikka
2013-09-17 00:07:56 +03:00
db7004e6aedcb's fd wasn't stored to client's protocol structure. Changed mysql_protocol_init to take fd as the Second argument.
vraatikka
2013-09-14 23:01:26 +03:00
4815856017session.c : session_alloc If backend connection can't be created, backend_dcb is not create, router client session is not created and what already is created in session_alloc, is freed. mysql_client.c : gw_read_client_event If session creation failed, then - instead of sending ok to client, "failed to create new session" is sent and client dcb is closed. : gw_MySQLAccept removed loop where accept was called again and again. With single thread looping forever is not possible because there's no one to free previously allocated resources. If accept fails ten times in a row, then return without new client dcb.
vraatikka
2013-09-13 23:55:26 +03:00
710fc5cfa6dcb.c : dcb_alloc switched malloc to calloc, dcb->fd is initialized to -1. : dcb_process_zombies return value of close(fd) is checked. Closed fds are stored to conn_open array. : dcb_connect assigns new fd only if backend connection succeeds. Dcb is added to poll set in the same way, only if connect succeed. gateway.c : conn_open array is initialized in main. For each created socket, a true is set to corresponding slot. Max. number of slots is 1024. mysql_client_server_protocol.h : gw_do_connect_to declaration mysql_backend.c : gw_create_backend_connection returns rv >= 0 and a protocol which is assigned to backend_dcb. In error, -1 is returned and fd is not set. mysql_client.c : conn_open array is kept up-to-date and protocol pointer is assigned also to dcb outside mysql_protocol_init. mysql_common.c : gw_do_connect_to_backend 3rd argument is pointer to fd, not protocol. dcb is added to poll set later in dcb_connect. skygw_debug.h : define conn_open[1024] array where open connections can be marked in debug build.
vraatikka
2013-09-13 22:10:40 +03:00
c3fba63b45Added break in routeQuery switch, avoiding the execution of default.
Massimiliano Pinto
2013-09-13 19:17:20 +02:00
b2b715fcaeFixed failed handshake handling, taking care of dcb->delayq before sending reply one time and not twice.
Massimiliano Pinto
2013-09-13 18:22:24 +02:00
88174865a0If accept fails due too many open fails, now ENFILE (system level file limit exceeded) and EMFILE (process limit) are separated and logged diffenretly.
vraatikka
2013-09-13 10:10:02 +03:00
ae12ef8f34Added call to close(fp_tmp)
vraatikka
2013-09-12 23:13:22 +03:00
d7e793a411poll.c:Returned checks for zombie mysql_backend.c:don't write to session->client if session->client is NULL mysql_common.c:assert if called with dcb==NULL
vraatikka
2013-09-12 22:34:49 +03:00
bbc9dcc9a3poll.c: added maxscale thread id to log session.c: Replaced free(session->router_sesision) with call to freeSession callback users.c: Removed reference to uninitialized variable. router.h: Added freeSession callback to function block. mysql_backend.c: try to ensure that client dcb is still listening in epoll_wait when writing reply to it. mysql_common.c: assert debug build is mysql_protocol_init is called with dcb == NULL readconnroute.c, readwritesplit.c, debugcli.c and testroute.c : Added freeSession to function block and an inmplementation of it.
vraatikka
2013-09-12 22:17:11 +03:00
c4d01cdaedBackend sets session's client pointer to NULL before session_free is called for session.
vraatikka
2013-09-12 22:10:43 +03:00
15adf134c4Defined LOGFILE_DEBUG for future use. If there will be separate logfile for debug output then macro will be removed. Currently equals with LOGFILE_TRACE.
vraatikka
2013-09-12 22:01:05 +03:00
3841f95531In error cases, called close(fp).
vraatikka
2013-09-12 22:00:08 +03:00
775b318889Added constants to gw_decode_mysql_server_handshake
Massimiliano Pinto
2013-09-12 16:08:31 +02:00
33fc1737d5One uninitialized read in dcb_set_state_nomutex. One read of freed memory in dcb_process_zombies. The former may have affected on the program behavior. The latter left in many cases fds open and dcbs not freed for real.
vraatikka
2013-09-12 10:00:55 +03:00
092795d95bin dcb_final_free the dcb->session NULL check protects the access to dcb->session->router_session and all the code below
Massimiliano Pinto
2013-09-10 15:50:47 +02:00
22e9fb9a4dBug 194: Crash starting listener if protocol module load fails
Mark Riddoch
2013-09-09 16:33:04 +02:00
6813f760a5Fix 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.
vraatikka
2013-09-09 15:00:37 +03:00
83a7479236Removed free(router_session) from closeSession. Router session is free in session.c:session_free.
vraatikka
2013-09-09 14:51:15 +03:00
46464d7723Check if router_session pointer has value in session structure before calling free for it.
vraatikka
2013-09-09 14:36:45 +03:00
e1d7a5640dPut structure check fields behind SS_DEBUG macros. Thus, they are only included in debug builds.
vraatikka
2013-09-09 10:05:46 +03:00
189fdf35b8Major changes: Removed NULL-pointer assignment after the call of backend_dcb->func.close because backend_dcb->func.close calls gw_client_close which _always_ returns true. Thus, its return value can't be used for deciding whether backend_dcb pointer can be set to NULL. There are typically multiple threads executing backend dcb. Setting NULL here will cause next caller to refer to NULL pointer, which makes maxscale to fail.
vraatikka
2013-09-08 23:59:00 +03:00
d2a61c3f82Added some checks and renamed according to changes made in elsewhere.
vraatikka
2013-09-08 23:38:38 +03:00
e7e44667c3Added some checks for return values.
vraatikka
2013-09-08 23:37:34 +03:00
a13396bc66Renamed struct CLIENT_SESSION to ROUTER_CLIENT_SESSION as it is router related thing. Client session refers more to SESSION. 'dcb' to 'backend_dcb' because it is more accurate. 'client_session' to 'router_client_session'.
vraatikka
2013-09-08 23:32:53 +03:00
d535346987Removed dead code.
vraatikka
2013-09-08 23:32:13 +03:00
e40aace963Renamed MySQLProtocol member 'descriptor' to 'owner_dcb'.
vraatikka
2013-09-08 23:31:05 +03:00
4c00cdac5eCleaned up. Removed unnecessary extern keywords from function declarations so to fit them better to one line.
vraatikka
2013-09-08 23:29:50 +03:00
e61c19c6feMajor change. router_session is freed as a last operation before freeing session. Fixes frequently occurring failures when multiple threads are running.
vraatikka
2013-09-08 23:27:57 +03:00
6a07ef8245Added debug logging to poll_remove_dcb. Removed dead code from poll_waitevents.
vraatikka
2013-09-08 23:26:15 +03:00
03fed73b64Added missing spinlock_release to dcb_add_to_zombieslist to avoid deadlock.
vraatikka
2013-09-08 23:24:54 +03:00
0d47aa2d3aRemove some contention on the DCB zombie queue spinlock
Mark Riddoch
2013-09-05 22:05:55 +02:00
66e9be814bdcb.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.
vraatikka
2013-09-05 22:00:02 +03:00
17ec98fa3dsession 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.
vraatikka
2013-09-05 19:47:42 +03:00
4f8057034aProtected temporarily with spinlock gethostbyname which is not thread safe. This should be changed permanently so that gethostbyname is replaced with getaddrinfo.
vraatikka
2013-09-05 19:42:59 +03:00
8f98ae4751Removed old mysql protocol files
Massimiliano Pinto
2013-09-04 15:53:51 +02:00
6888735f7bRemoved old gateway_mysql_protocol.c server/core/Makefile updtated
Massimiliano Pinto
2013-09-04 15:41:08 +02:00
b01cf2365eAdded log error or ss_dassert instead of silent returning
Massimiliano Pinto
2013-09-04 15:31:04 +02:00
5c48239372Fixed doxygen documentation generation
Mark Riddoch
2013-09-04 13:13:54 +02:00
f74f67540fAdded 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.
Mark Riddoch
2013-09-04 12:24:59 +02:00
8debc4433cAdded a client NULL check in clientReply
Massimiliano Pinto
2013-09-04 11:37:56 +02:00
3d5c40e450Removed unused macros. Fixed struct member order so that check field is again the last in struct and it detects memory overflows slightly better.
vraatikka
2013-09-02 21:54:24 +03:00
366441a4bbAdded debug assert for checking return value of memory allocation.
vraatikka
2013-09-02 21:53:49 +03:00
c4ce2efd9fAdded debug assert for DCB states prior processing.
vraatikka
2013-09-02 21:52:57 +03:00
5487f84532Added logging to session refcount increment. Some minor improvements.
vraatikka
2013-09-02 21:52:09 +03:00
f80bb51db1dcb_close sets some session fields to NULL:
Massimiliano Pinto
2013-09-02 19:33:55 +02:00
31cda5ad65Added session refcount in session.h
Massimiliano Pinto
2013-09-02 10:26:34 +02:00
b86d3f3dfdHolding error log's block buffer registration until all logs were written caused deadlock if block buffers were full. Now buffer registrations don't overlap.
vraatikka
2013-09-02 10:30:50 +03:00
757a043386Replaced oinlined protocol creation with call to mysql_protocol_init. Clean up.
vraatikka
2013-09-01 00:36:31 +03:00
9df2040a8aRemoved unused variables, changed call to mysql_protocol_init to reflect new prototype.
vraatikka
2013-09-01 00:32:57 +03:00
88ffcaa3d4Removed 'extern' keyword from function declaration in headers. Functions are 'extern' by default. Changed mysql_protocol_init prototype and implementation to return MySQLProtocol pointer instead of boolean.
vraatikka
2013-09-01 00:30:46 +03:00
3dff91e80fIn gw_create_backend_connection, replaced inlined protocol init with call to mysql_protocol_init (mysql_common.c). Replaced fprintfs with logging commands.
vraatikka
2013-08-31 23:51:54 +03:00
c23168ed71gw_do_connect_to_backend returned zero in case where connect failed with errno EINPROGRESS. Should have returned 1 to indicate that connection will be established asynchronously.
vraatikka
2013-08-31 23:45:40 +03:00
9d6b13c288Replaced macros with enumereted type.
vraatikka
2013-08-31 12:04:02 +03:00
a445b6ff37Fixes for NULL test for function returns such as malloc() - as reported by Coverity
Mark Riddoch
2013-08-29 13:34:21 +02:00
03725cabe3Fixed compile issue in dcb.h
Mark Riddoch
2013-08-29 13:17:19 +02:00
94a8ad68d3Checked for bug #178. Added error logs to suitabl places.
vraatikka
2013-08-29 09:50:16 +03:00
48165bf5cdRemoved unused protocol_mutex and references to it.
vraatikka
2013-08-28 23:25:27 +03:00
134c33776eAdded consistency check fields, and switched macros to enumerated types.
vraatikka
2013-08-28 23:23:05 +03:00
50a3cfdf49Commented out some dead code.
vraatikka
2013-08-28 23:17:18 +03:00
ae9fce8591Added 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.
vraatikka
2013-08-28 23:09:37 +03:00