Files
MaxScale/server/modules/include/readwritesplit.h
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

93 lines
3.2 KiB
C

#ifndef _RWSPLITROUTER_H
#define _RWSPLITROUTER_H
/*
* This file is distributed as part of the SkySQL Gateway. It is free
* software: you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation,
* version 2.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright SkySQL Ab 2013
*/
/**
* @file router.h - The read write split router module heder file
*
* @verbatim
* Revision History
*
* Tässä mitään historioita..
*
* @endverbatim
*/
#include <dcb.h>
/**
* Internal structure used to define the set of backend servers we are routing
* connections to. This provides the storage for routing module specific data
* that is required for each of the backend servers.
*/
typedef struct backend {
SERVER* backend_server; /**< The server itself */
int backend_conn_count; /**< Number of connections to the server */
} BACKEND;
/**
* The client session structure used within this router.
*/
typedef struct router_client_session {
#if defined(SS_DEBUG)
skygw_chk_t rses_chk_top;
#endif
SPINLOCK rses_lock; /**< protects rses_deleted */
int rses_versno; /**< even = no active update, else odd */
bool rses_closed; /**< true when closeSession is called */
BACKEND* be_slave; /**< Slave backend used by client session */
BACKEND* be_master; /**< Master backend used by client session */
DCB* slave_dcb; /**< Slave connection */
DCB* master_dcb; /**< Master connection */
struct router_client_session* next;
#if defined(SS_DEBUG)
skygw_chk_t rses_chk_tail;
#endif
} ROUTER_CLIENT_SES;
/**
* The statistics for this router instance
*/
typedef struct {
int n_sessions; /**< Number sessions created */
int n_queries; /**< Number of queries forwarded */
int n_master; /**< Number of stmts sent to master */
int n_slave; /**< Number of stmts sent to slave */
int n_all; /**< Number of stmts sent to all */
} ROUTER_STATS;
/**
* The per instance data for the router.
*/
typedef struct router_instance {
SERVICE* service; /**< Pointer to service */
ROUTER_CLIENT_SES* connections; /**< List of client connections */
SPINLOCK lock; /**< Lock for the instance data */
BACKEND** servers; /**< Backend servers */
BACKEND* master; /**< NULL or pointer */
unsigned int bitmask; /**< Bitmask to apply to server->status */
unsigned int bitvalue; /**< Required value of server->status */
ROUTER_STATS stats; /**< Statistics for this router */
struct router_instance* next; /**< Next router on the list */
} ROUTER_INSTANCE;
#endif