From 25314b6662d57343eaf7cbff94c92b75078ab9bc Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Fri, 2 Jun 2017 15:53:48 +0300 Subject: [PATCH] MXS-1275: Add client protocol data to MXS_SESSION The current sql mode will be tracked in that variable. Since one thread will handle multiple sessions, we need to track the sql mode of a session, so that the sql mode of the query classifier can be set whenever we handle a request of a particular session. As the sql-mode will be managed by the client protocol, the data can be private to it as well. --- include/maxscale/session.h | 29 +++++++++++++++-------------- server/core/maxscale/session.h | 2 +- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/include/maxscale/session.h b/include/maxscale/session.h index a85b9292a..31f21061c 100644 --- a/include/maxscale/session.h +++ b/include/maxscale/session.h @@ -126,20 +126,21 @@ typedef struct mxs_upstream typedef struct session { skygw_chk_t ses_chk_top; - mxs_session_state_t state; /*< Current descriptor state */ - size_t ses_id; /*< Unique session identifier */ - struct dcb *client_dcb; /*< The client connection */ - void *router_session; /*< The router instance data */ - MXS_SESSION_STATS stats; /*< Session statistics */ - struct service *service; /*< The service this session is using */ - int n_filters; /*< Number of filter sessions */ - SESSION_FILTER *filters; /*< The filters in use within this session */ - MXS_DOWNSTREAM head; /*< Head of the filter chain */ - MXS_UPSTREAM tail; /*< The tail of the filter chain */ - int refcount; /*< Reference count on the session */ - bool ses_is_child; /*< this is a child session */ - mxs_session_trx_state_t trx_state; /*< The current transaction state. */ - bool autocommit; /*< Whether autocommit is on. */ + mxs_session_state_t state; /*< Current descriptor state */ + size_t ses_id; /*< Unique session identifier */ + struct dcb *client_dcb; /*< The client connection */ + void *router_session; /*< The router instance data */ + MXS_SESSION_STATS stats; /*< Session statistics */ + struct service *service; /*< The service this session is using */ + int n_filters; /*< Number of filter sessions */ + SESSION_FILTER *filters; /*< The filters in use within this session */ + MXS_DOWNSTREAM head; /*< Head of the filter chain */ + MXS_UPSTREAM tail; /*< The tail of the filter chain */ + int refcount; /*< Reference count on the session */ + bool ses_is_child; /*< this is a child session */ + mxs_session_trx_state_t trx_state; /*< The current transaction state. */ + bool autocommit; /*< Whether autocommit is on. */ + intptr_t client_protocol_data; /*< Owned and managed by the client protocol. */ struct { GWBUF *buffer; /**< Buffer containing the statement */ diff --git a/server/core/maxscale/session.h b/server/core/maxscale/session.h index dbf11c6ff..7c029d159 100644 --- a/server/core/maxscale/session.h +++ b/server/core/maxscale/session.h @@ -27,7 +27,7 @@ MXS_BEGIN_DECLS #define SESSION_INIT {.ses_chk_top = CHK_NUM_SESSION, \ .stats = SESSION_STATS_INIT, .head = MXS_DOWNSTREAM_INIT, .tail = MXS_UPSTREAM_INIT, \ - .state = SESSION_STATE_ALLOC, .ses_chk_tail = CHK_NUM_SESSION} + .state = SESSION_STATE_ALLOC, .client_protocol_data = 0, .ses_chk_tail = CHK_NUM_SESSION} #define SESSION_PROTOCOL(x, type) DCB_PROTOCOL((x)->client_dcb, type)