Divide session.h to internal and interface headers

Definitions and function used by core are in
server/core/maxscale/session.h
Definitions and function used by plugins are in
include/maxscale/session.h
This commit is contained in:
Esa Korhonen
2017-01-18 17:55:42 +02:00
parent c9a61fec6d
commit 02a8f7492e
7 changed files with 131 additions and 108 deletions

View File

@ -13,33 +13,18 @@
*/
/**
* @file session.h
*
* @verbatim
* Revision History
*
* Date Who Description
* 01-06-2013 Mark Riddoch Initial implementation
* 14-06-2013 Massimiliano Pinto Added void *data to session
* for session specific data
* 01-07-2013 Massimiliano Pinto Removed backends pointer
* from struct session
* 02-09-2013 Massimiliano Pinto Added session ref counter
* 29-05-2014 Mark Riddoch Support for filter mechanism
* added
* 20-02-2015 Markus Mäkelä Added session timeouts
* 27/06/2016 Martin Brampton Modify session struct for list manager
*
* @endverbatim
* @file include/maxscale/session.h - The public session interface
*/
#include <maxscale/cdefs.h>
#include <time.h>
#include <maxscale/atomic.h>
#include <maxscale/buffer.h>
#include <maxscale/spinlock.h>
#include <maxscale/resultset.h>
#include <maxscale/log_manager.h>
#include <maxscale/resultset.h>
#include <maxscale/spinlock.h>
MXS_BEGIN_DECLS
@ -48,16 +33,6 @@ struct service;
struct mxs_filter_def;
struct server;
/**
* The session statistics structure
*/
typedef struct
{
time_t connect; /**< Time when the session was started */
} SESSION_STATS;
#define SESSION_STATS_INIT {0}
typedef enum
{
SESSION_STATE_ALLOC, /*< for all sessions */
@ -92,39 +67,12 @@ typedef enum
} mxs_session_trx_state_t;
/**
* Convert transaction state to string representation.
*
* @param state A transaction state.
* @return String representation of the state.
* The session statistics structure
*/
const char* session_trx_state_to_string(mxs_session_trx_state_t state);
/**
* The downstream element in the filter chain. This may refer to
* another filter or to a router.
*/
typedef struct mxs_downstream
typedef struct
{
void *instance;
void *session;
int32_t (*routeQuery)(void *instance, void *session, GWBUF *request);
} MXS_DOWNSTREAM;
#define MXS_DOWNSTREAM_INIT {0}
/**
* The upstream element in the filter chain. This may refer to
* another filter or to the protocol implementation.
*/
typedef struct mxs_upstream
{
void *instance;
void *session;
int32_t (*clientReply)(void *instance, void *session, GWBUF *response);
int32_t (*error)(void *instance, void *session, void *);
} MXS_UPSTREAM;
#define MXS_UPSTREAM_INIT {0}
time_t connect; /**< Time when the session was started */
} MXS_SESSION_STATS;
/**
* Structure used to track the filter instances and sessions of the filters
@ -137,16 +85,28 @@ typedef struct
void *session;
} SESSION_FILTER;
#define SESSION_FILTER_INIT {0}
/**
* The downstream element in the filter chain. This may refer to
* another filter or to a router.
*/
typedef struct mxs_downstream
{
void *instance;
void *session;
int32_t (*routeQuery)(void *instance, void *session, GWBUF *request);
} MXS_DOWNSTREAM;
/**
* Filter type for the sessionGetList call
* The upstream element in the filter chain. This may refer to
* another filter or to the protocol implementation.
*/
typedef enum
typedef struct mxs_upstream
{
SESSION_LIST_ALL,
SESSION_LIST_CONNECTION
} SESSIONLISTFILTER;
void *instance;
void *session;
int32_t (*clientReply)(void *instance, void *session, GWBUF *response);
int32_t (*error)(void *instance, void *session, void *);
} MXS_UPSTREAM;
/**
* The session status block
@ -167,7 +127,7 @@ typedef struct session
int enabled_log_priorities; /*< Bitfield of enabled syslog priorities */
struct dcb *client_dcb; /*< The client connection */
void *router_session; /*< The router instance data */
SESSION_STATS stats; /*< Session statistics */
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 */
@ -185,12 +145,6 @@ typedef struct session
skygw_chk_t ses_chk_tail;
} MXS_SESSION;
#define SESSION_INIT {.ses_chk_top = CHK_NUM_SESSION, .ses_lock = SPINLOCK_INIT, \
.stats = SESSION_STATS_INIT, .head = MXS_DOWNSTREAM_INIT, .tail = MXS_UPSTREAM_INIT, \
.state = SESSION_STATE_ALLOC, .ses_chk_tail = CHK_NUM_SESSION}
#define SESSION_PROTOCOL(x, type) DCB_PROTOCOL((x)->client_dcb, type)
/**
* A convenience macro that can be used by the protocol modules to route
* the incoming data to the first element in the pipeline of filters and
@ -210,21 +164,20 @@ typedef struct session
MXS_SESSION *session_alloc(struct service *, struct dcb *);
MXS_SESSION *session_set_dummy(struct dcb *);
int session_isvalid(MXS_SESSION *);
int session_reply(void *inst, void *session, GWBUF *data);
const char *session_get_remote(const MXS_SESSION *);
const char *session_get_user(const MXS_SESSION *);
void printAllSessions();
void printSession(MXS_SESSION *);
void dprintSessionList(DCB *pdcb);
void dprintAllSessions(struct dcb *);
void dprintSession(struct dcb *, MXS_SESSION *);
void dListSessions(struct dcb *);
char *session_state(mxs_session_state_t);
bool session_link_dcb(MXS_SESSION *, struct dcb *);
void session_enable_log_priority(MXS_SESSION* ses, int priority);
void session_disable_log_priority(MXS_SESSION* ses, int priority);
RESULTSET *sessionGetList(SESSIONLISTFILTER);
/**
* Convert transaction state to string representation.
*
* @param state A transaction state.
* @return String representation of the state.
*/
const char* session_trx_state_to_string(mxs_session_trx_state_t state);
/**
* Get the transaction state of the session.
@ -356,22 +309,11 @@ static inline bool session_set_autocommit(MXS_SESSION* ses, bool autocommit)
*/
MXS_SESSION* session_get_by_id(int id);
/**
* @brief Get a session reference
*
* This creates an additional reference to a session which allows it to live
* as long as it is needed.
*
* @param session Session reference to get
* @return Reference to a MXS_SESSION
*
* @note The caller must free the session reference by calling session_put_ref
*/
MXS_SESSION* session_get_ref(MXS_SESSION *sessoin);
/**
* @brief Release a session reference
*
* This function is public only because the tee-filter uses it.
*
* @param session Session reference to release
*/
void session_put_ref(MXS_SESSION *session);