74 Commits

Author SHA1 Message Date
Markus Makela
0e53633a37 Merge remote-tracking branch 'origin/Z3' into MAX-237 2014-09-01 13:44:24 +03:00
Markus Makela
164d8b1e32 Fixed various memory leaks
dbuser.c: key.user value was never freed
skygw_utils.cc: replace_literal values were not always freed
2014-09-01 13:40:52 +03:00
VilhoRaatikka
20abbbdf57 query_classifier.cc:skygw_get_canonical: Fixed bug in how strings were passed to replace_literal function. Changed to use item->str_ptr which stores all strings in the same way unlike item->name in which some string values have double quotation.
skygw_utils.cc:Fixed regexp so that it detects literals at the end of line too.
2014-09-01 13:23:04 +03:00
VilhoRaatikka
40416d424e Merge branch 'Z3' of https://github.com/skysql/MaxScale into Z3
Conflicts:
	gcov.diff
	server/core/buffer.c
	server/include/buffer.h
	server/modules/routing/readwritesplit/readwritesplit.c
2014-08-29 18:50:32 +03:00
VilhoRaatikka
69104d7dee skygw_utils.cc:replace_literal: Fixed regular expression which, for example, accepted "200" with needle "2"
query_classifier.cc: fixed invalid argument list in logging command.
input.sql: added a few previously failed cases for canonical query test
2014-08-26 11:08:05 +03:00
VilhoRaatikka
ee52ac64a9 query_classifier.cc:skygw_get_canonical: if the item to be replaced is an empty string "", it is processed differently from the other cases due to difficulties to get wanted result by adding special rule for that to regex.
query_classifier.h: added parsing information structure to query classifier away from buffer.h.
buffer.c:introduced a buffer object which includes object pointer and a clean-up call-back function. Buffer objects form a list which is cleaned up by the last referrer of the buffer, as a part of gwbuf_free. Buffer object list is protected by a spinlock gwbuf_lock.
	Also added identifier type, bufobj_id_t which is enumerated type and currently includes one value only, GWBUF_PARSING_INFO. Added also a bitfield for information about the buffer. It currently has one type only, GWBUF_INFO_PARSED indicating that buffer content is parsed and there is buffer object of type GWBUF_PARSING_INFO.
skygw_utils.cc:replace_literal:changed regexec matching to case insensitive because user-defined literals are sometimes converted to upper-case ones.
2014-08-22 19:01:56 +03:00
VilhoRaatikka
3a5b8ef64c query_classifier.cc: cleaned up and simplified skygw_get_canonical
skygw_util.cc:fixed memory allocation issue where terminating byte wasn't counted. Added some error checks.
2014-08-21 23:08:21 +03:00
VilhoRaatikka
8d1eae6fde Fixed comment. 2014-08-21 22:34:50 +03:00
VilhoRaatikka
fa2189373d query_classifier.cc: query_is_parsed is now global function and can be used to check whether parsing information already exists in the buffer.
skygw_utils.cc: removed replace_str and implemented replace_literal which replaces user-provided literals in query with predefined string "?". Replacing is done one by one, so it is suboptimal ipmlementation since all literals could be passed to replacement function in one call and processed all before returning.
2014-08-21 22:28:23 +03:00
VilhoRaatikka
c501d4d4e1 Changes related to canonical query format implementation.
query_classifier.cc: Now query can be parsed outside query_classifier_get_type by calling function parse_query. It creates parsing_info_t struct which is then added to the GWBUF which also includes the query. Parsing information follows the buffered query and it is freed at the same time with query buffer, in gwbuf_free.
buffer.c: additions of parsing information to gwbuf struct.
modutil.c: added function which returns query from GWBUF in plain text string.
readwritesplit.c:routeQuery now only calls query_classifier_get_type to get the query type instead of extracting plain text query from the GWBUF buffer.
2014-08-20 22:10:36 +03:00
VilhoRaatikka
544e64a301 query_classifier: implemented skygw_get_canonical which returns a copy of original string with given substrings being replaced with questionmarks.
skygw_utils.cc: added string replacement function for use of skygw_get_canonical
2014-08-18 14:19:46 +03:00
VilhoRaatikka
b72e80b464 Fix for Bug #466, http://bugs.skysql.com/show_bug.cgi?id=466
hintparser.c:hint_parser:when string token is found, create a copy of the token value instead of copying the its address because token will be freed before the value is used.
	hint_next_token:didn't recognize '=' as TOK_EQUAL, fixed that. Read the code.
hint.c:hint_create_parameter: copy the pointer to parameter name instead of creating copy of it - pname is already copied from token before the call
readwritesplit.c:routeQuery:Hint name was copied when hint value was supposed to be copied, thus resulting invalid value for hinted parameter. Also fixed server type in trace log command.
skygw_debug.h:Added string for Relay server to macro STRSRVSTATUS.
2014-08-06 16:39:22 +03:00
VilhoRaatikka
cf38dad43a Merge branch 'Z2' of https://github.com/skysql/MaxScale into Z2
Conflicts:
	server/core/modutil.c
2014-08-05 18:26:55 +03:00
VilhoRaatikka
08b99c121e Bug #468, http://bugs.skysql.com/show_bug.cgi?id=468, Query classifier accessed freed thread context. If parsing fails thd doesn't need to be freed because it holds correct information about command type.
session.c:session_setup_filters : fixed memory leak
hintparser.c: added token_free for HINT_TOKENs and fixed a few memory leaks.
mysql_client_server_protocol.h: added mysql_protocol_done which frees memory blocks pointed to by protocol members. Those can't be freed in dcb.c because dcb.c doesn't know about protocol's members.
mysql_backend.c:gw_backend_close: fixed memory leak
mysql_client.c: gw_client_close: fixed memory leak
mysql_common.c: added implementation of mysql_protocol_done
        :protocol_archive_srv_command: tried to fix memory leak. Some memory is still leaking according to valgrind. Removed use of uninitialized local variable len.
readwritesplit.c: Fix to bug #469, http://bugs.skysql.com/show_bug.cgi?id=469,  rwsplit counts every connection twice in master - counnection counts leak
	execute_sescmd_in_backend: fixed a memory leak - visible only in DEBUG=Y build.
readwritesplit/test/makefile: added target for hints tests
2014-08-05 18:14:06 +03:00
MassimilianoPinto
490ade606a Updated RUNNING NDB desc
Updated RUNNING NDB desc
2014-08-05 16:20:56 +02:00
VilhoRaatikka
8ffca16368 Added consistency check for detect_replication_lag and max_slave_replication_lag and router_options=slave_select_criteria=LEAST_BEHIND_MASTER
Fixed a bug in service_add_qualified_param which didn't handle param list correctly.
2014-07-01 16:54:16 +03:00
VilhoRaatikka
dff18bf9bb Necessary checks and macros for prepared statement support implementation. 2014-06-25 17:37:37 +03:00
MassimilianoPinto
4dbd51b1fc fixed macro name
fixed macro name
2014-06-04 13:15:01 +02:00
VilhoRaatikka
46495bb59e Bug #443, http://bugs.skysql.com/show_bug.cgi?id=443
monitors used mysql_ping without MYSQL_OPT_READ_TIMEOUT which caused read to block. Fixed in mysql and galera monitor.
Added log writing per each status change of each server and repeatedly if server is not running.

Removed SERVER_IS_JOINED checks from rwsplit router.
2014-06-03 19:39:50 +03:00
VilhoRaatikka
c5ec3cbc57 Added new criteria for slave selection: LEAST_ROUTER_CONNECTIONS which causes the servers having least connections from same router to become chosen.
Added function pointer array which is indexed by enumerated selection criterias.
Selection criteria can now be switched by modifying config file and reloading it.
2014-05-12 17:03:22 +03:00
VilhoRaatikka
c927057b5c Fixed two bugs of which one was older.
1. in query_classifier.cc autocommit_enabled, and transaction_active variables maintained their values across different sessions. Now those values are stored in each router_client_ses object.
2. As a part of implementation of MAX-95 session variables were added to BACKEND struct which is shared with all sessions using the SERVICE which the particular BACKEND serves. Now each router_client_ses object has a backend reference struct which includes pointer to BACKEND, DCB and to session command cursor.

Added test - set_autocommit_disabled.sql, test_after_autocommit_disabled.sql - to check that session variable is discarded when session where it belongs terminates.
2014-04-28 23:33:49 +03:00
VilhoRaatikka
04313caf82 Initial implementation of the support for multiple slaves in read/write split router session. Omits configuration changes. 2014-04-23 14:55:04 +03:00
VilhoRaatikka
c28892323a Added support for session commands to readwrite split router.
Added support for multi-statement packets.

This is an intermediate commit to save work. Code is not cleaned and there are debug prints and prototypes to be removed.
2014-03-07 20:53:33 +02:00
VilhoRaatikka
3e111534a1 Support for mysql session variable commands, for example, SET AUTOCOMMIT=0
Session commands are identified by query clasisfier, and added to the session command property list in router client session object.
Session commands are then executed in existing backend servers but only one of them will reply to client.
2014-02-26 20:07:09 +02:00
VilhoRaatikka
e57944ef44 Bug #399, http://bugs.skysql.com/show_bug.cgi?id=399
Corrected the length variable including length of timestampt string which doesn't include terminating null.
2014-02-11 14:55:16 +02:00
VilhoRaatikka
75af5ee03c Merge https://github.com/skysql/MaxScale 2014-02-07 11:11:47 +02:00
VilhoRaatikka
e8ce2268e0 Test system for MaxScale.
Every test/makefile have the following targets:
 cleantests 	- clean local and subdirectories' tests
 buildtests	- build all local and subdirectories' tests
 runtests	- run all local tests
 testall	- clean, build and run local and subdirectories' tests

Tests for directory random_dir are always in its subdirectory, in this case in random_dir/test . If random_dir has subdirectories with tests, random_dir/child_dir, for example, tests of child_dir can be started from random_dir/test/makefile where make -C child_dir/test <test target> is called.

See MAXSCALE_HOME/test/README for further information.
2014-02-07 11:06:37 +02:00
Mark Riddoch
3edea0afc4 Updated gitignore files 2014-02-05 14:49:05 +01:00
vraatikka
f50de7a084 build_gateway.inc
Removed MARIADB_SRC_PATH
	Added MYSQL_ROOT - root directory where MariaDB headers are installed
	Added MYSQL_HEADERS - -I notation for three header directories
	Added EMBEDDED_LIB - for embedded library directory
	Added ERRMSG - for errmsg.sys file

log_manager.cc
	Little fixes

log_manager/makefile
	Updated header include directive

makefile.inc
	Removed DEBUGGER and BACKGR as unnecessary
	Added LIB for embedded library file name

query_classifier/makefile
	Updated header include directives and embedded library directory

query_classifier/query_classifier.cc
	clean up

server/core/Makefile
	Updated header include directives and embedded library directory
	Added libaio and install of errmsg.sys

server/core/dcb.c
	clean up

server/core/gateway.c
	Added --language and --skip-innodb to mysql_library_init command-line arguments list
	clean up

server/core/load_utils.c
	clean up

server/modules/monitor/Makefile
server/modules/routing/readwritesplit/Makefile
	Updated header include directives and embedded library directory

utils/skygw_debug.h
	http://bugs.skysql.com/show_bug.cgi?id=369

utils/skygw_types.h
utils/skygw_utils.cc
	clean up
2013-12-06 00:12:41 +02:00
vraatikka
41298a09df Bugzilla entry # 363:
skygw_thread_t and simple_mutex_t make own copy of name argrument. Changed init calls to both accordingly.
2013-11-27 10:51:45 +02:00
vraatikka
bc97b7f5ec log_manager.cc
external optind variable must be reset before using it because getopt may have been called earlier in the same process and without resetting argument parsing fails.

dcb.c
	check dcb state before attempting to write to dcb in dcb_write

gateway.c
	daemon_mode moved to global so that it can be taken into account when deciding where to print messages.
	added get_config_filename by using home directory name given as a parameter. Returns absolute paths to config file and to home directory regardless of home directory argument was relative of absolute.
	In main, arguments are parsed by using getopt.
	Changed argument '-c' to specify home directory because MaxScale.cnf is always in <home>/etc/ directory.
	Added argument '-m' to specify modules directory. Both arguments override any other settings.

skygw_types.h
	Added PATH_MAX
2013-11-26 12:53:46 +02:00
vraatikka
3b0d6c23ad log_manager.cc
Commented why spread-down logging is disabled. 
	In MaxScale start, log paths are printed in their complete form to make it easier to copy-paste the names.

gateway.c
	Replaced print_signal_set_error with more general-purpose print_log_n_stderr which prints non-formatted messages to error log and to stderr to the point MaxScale switches to run in daemon process. After that only error log is printed.

skyge_utils.cc
	polish
2013-11-25 10:49:45 +02:00
vraatikka
1a3fa578da Fixed snprint_timestamp function which left one byte garbage to log file. 2013-11-12 17:49:28 +02:00
vraatikka
9ba7a0d955 log_manager.cc
Added new argument '-s' which takes additional argument composed of list of logfile identifiers. Logfiles listed with '-s' will be written on main memory instead of disk. In practice, the log file in question will be written in /dev/shm but corresponding symlink is added to log directory. In the case of name conflicts with log files and links, a differentiating sequence number is included in hte name of the file. This, however, is done only when existing file is not writable or is of different type (symlink <> file). 
	Added new logfile LOGFILE_DEBUG whose contents will be largerly what was included up to date in trace log. 

	Disabled feature which spreads writes to log files to others because of bug (#338) in the way block buffers are managed.

	Changed log manager parameters to match with the current implementation. List of arguments:
                "-h - help\n"
                "-a <debug prefix>   ............(\"skygw_debug\")\n"
                "-b <debug suffix>   ............(\".log\")\n"
                "-c <trace prefix>   ............(\"skygw_trace\")\n"
                "-d <trace suffix>   ............(\".log\")\n"
                "-e <message prefix> ............(\"skygw_msg\")\n"
                "-f <message suffix> ............(\".log\")\n"
                "-g <error prefix>   ............(\"skygw_err\")\n"
                "-i <error suffix>   ............(\".log\")\n"
                "-j <log path>       ............(\"/tmp\")\n"
                "-s <shmem log file ids> ........(no default)\n";

dcb.c
	dcb_add_to_zombieslist, add dcb to the front of zombies list instead of inserting to the end of it.

gateway.c
	Renamed shutdown_gateway to shutdown_server (Bug #131)
	Call skygw_logmanager_init so that trace and debug logs are written to shared memory.

poll.c 
dcb.h
	Removed some dead code and references to unneeded mutexes.

debugcmd.c
	Added enable/disable log command for debug log.

skygw_utils.cc
	skygw_file_init now takes optional symlink name as a second argument. Symlink is created to point to the file being created.
2013-11-08 12:56:39 +02:00
vraatikka
594f1c294f Added include of stdlib.h because malloc needs it to work. Malloc time to time fails in server/core/buffer.c and produces the following error:
*** Error in `./maxscale': malloc(): memory corruption (fast): 0x00007f3988005510 ***
======= Backtrace: =========
/lib64/libc.so.6(+0x7afc6)[0x7f39c67a9fc6]
/lib64/libc.so.6(+0x7d245)[0x7f39c67ac245]
/lib64/libc.so.6(__libc_malloc+0x63)[0x7f39c67ad633]
./maxscale(gwbuf_alloc+0x34)[0x406250]
/home/raatikka/bin/tmp/MaxScale/modules/libMySQLClient.so(MySQLSendHandshake+0x19b)[0x7f39afb09bc0]
/home/raatikka/bin/tmp/MaxScale/modules/libMySQLClient.so(+0x4d1b)[0x7f39afb0ad1b]
./maxscale(poll_waitevents+0x42a)[0x40d0c3]
/lib64/libpthread.so.0(+0x7e0f)[0x7f39c6ae5e0f]
/lib64/libc.so.6(clone+0x6d)[0x7f39c681844d]
======= Memory map: ========
00400000-0041a000 r-xp 00000000 08:03 6686345                            /home/raatikka/bin/tmp/bin/maxscale
00619000-0061a000 r--p 00019000 08:03 6686345                            /home/raatikka/bin/tmp/bin/maxscale
0061a000-0061b000 rw-p 0001a000 08:03 6686345                            /home/raatikka/bin/tmp/bin/maxscale
012fa000-0141e000 rw-p 00000000 00:00 0                                  [heap]
7f3984000000-7f3984021000 rw-p 00000000 00:00 0 

- and so forth.
2013-11-03 20:54:41 +02:00
vraatikka
e803acb036 dcb.c, gateway.c little tuning.
poll.c
	Removed mutex from epoll_wait.
	Removed read and write mutexes from poll_waitevents.

session.c
	If session_alloc fails, instead of calling directly free(session), call session_free, which decreases refcounter and only frees session when there are no references left. 
	Added session_unlink_dcb function which removes link from session and optionally sets the dcb->session pointer to NULL.

readconnection.h, readwritesplit.h
	Added check fields to ROUTER_CLIENT_SES strct as well as lock, version number (not used yet) and closed flag.

mysql_backend.c
	gw_read_backend_event: if backend_protocol->state was set to MYSQL_AUTH_RECV, function returned, which was unnecessary. If mysql state became MYSQL_AUTH_FAILED, router client session was closed. Removed unnecessary NULL checks because rsession is not allowed to be NULL. Similarly, removed other NULL checks and replaced them with asserts checking that router client session is not NULL at any phase.

mysql_client.c
	Removed unused code blocks. Polished log commands. Replaced router client sessions NULL checks with asserts.

mysql_common.c
	mysql_send_custom_error: if called with dcb == NULL, return.

readconnroute.c
	Replaced malloc with calloc. Added functions rses_begin_router_action and rses_exit_router_action. If router client session is not closed, they take a lock and release it, respectively. Those functions are used for protecting all operations which modify the contents of router client session struct.

readwritesplit.c
	Identical changes than in readconnroute.c

skygw_debug.h
	Added check number and - macro for ROUTER_CLIENT_SES, and added COM_QUIT to STRPACKETTYPE.
2013-10-30 22:07:51 +02:00
vraatikka
f32cfe8546 query_classifier.cc
resolve_query_type, traverse through the list of items of thd->free_list, identify functions and reason query type according to the function type. This phase can only increase the restrictiviness level of the query.

query_classifier.h
        Added new query type QUERY_TYPE_LOCAL_READ, for functions that can be executed in Maxscale. This type is the least restrict
ive query type. It is not used currently.

testmain.c
	Added a few test cases and fixed expected return values for query type tests.

readwritesplit.c
	polish

skygw_debug.h
	Added string macro for Item types.
2013-10-25 11:55:45 +03:00
vraatikka
da60fe701c Cleanup, added also a macro for printing dcb state. 2013-10-23 09:11:20 +03:00
vraatikka
44c7914f2b Increased size of following arrays to prevent memory overwrites: dcb_fake_write_errno, dcb_fake_write_ev, conn_open. Note that these are use in DEBUG build only. 2013-10-16 17:32:30 +03:00
vraatikka
cd507f1461 log_manager.cc
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).
2013-10-10 16:46:51 +03:00
vraatikka
80b67d1083 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.:
2013-10-06 22:31:32 +03:00
vraatikka
74aa3638f9 dcb.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.

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.
2013-09-20 14:32:28 +03:00
vraatikka
4cf5b3293f Added check routine for gw_buffer. Only effective in debug build. 2013-09-17 15:10:16 +03:00
vraatikka
710fc5cfa6 dcb.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.
2013-09-13 22:10:40 +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
vraatikka
34b26ad85f Changed enum-type boolean to whta is defined in stdbool.h, and in practise replaced TRUEs and FALSEs with true, and false, respectively. 2013-08-28 22:47:14 +03:00
vraatikka
17975a1252 Fixed indentation. 2013-08-23 22:29:31 +03:00
vraatikka
4138281183 setvbuf was called before testing whether file creation succeed. That caused server to fail if MAXSCALE_HOME was exceptionally long. 2013-08-22 00:32:49 +03:00
vraatikka
4360ae16b8 Moved timestamp string creation to skygw_utils where it can be provide service for others too. 2013-08-12 13:09:29 +03:00
vraatikka
0ad25ba3ab Added functions skygw_log_enable(logfile_id_t) and skygw_log_disable(logfile_id_t) to Log manager API. By calling them log writing to any of predefined log files can be switched on or off.
Added simple test to testlog.c
2013-08-08 23:38:00 +03:00