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:
@ -13,33 +13,18 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file session.h
|
* @file include/maxscale/session.h - The public session interface
|
||||||
*
|
|
||||||
* @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
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <maxscale/cdefs.h>
|
#include <maxscale/cdefs.h>
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#include <maxscale/atomic.h>
|
#include <maxscale/atomic.h>
|
||||||
#include <maxscale/buffer.h>
|
#include <maxscale/buffer.h>
|
||||||
#include <maxscale/spinlock.h>
|
|
||||||
#include <maxscale/resultset.h>
|
|
||||||
#include <maxscale/log_manager.h>
|
#include <maxscale/log_manager.h>
|
||||||
|
#include <maxscale/resultset.h>
|
||||||
|
#include <maxscale/spinlock.h>
|
||||||
|
|
||||||
MXS_BEGIN_DECLS
|
MXS_BEGIN_DECLS
|
||||||
|
|
||||||
@ -48,16 +33,6 @@ struct service;
|
|||||||
struct mxs_filter_def;
|
struct mxs_filter_def;
|
||||||
struct server;
|
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
|
typedef enum
|
||||||
{
|
{
|
||||||
SESSION_STATE_ALLOC, /*< for all sessions */
|
SESSION_STATE_ALLOC, /*< for all sessions */
|
||||||
@ -92,39 +67,12 @@ typedef enum
|
|||||||
} mxs_session_trx_state_t;
|
} mxs_session_trx_state_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert transaction state to string representation.
|
* The session statistics structure
|
||||||
*
|
|
||||||
* @param state A transaction state.
|
|
||||||
* @return String representation of the state.
|
|
||||||
*/
|
*/
|
||||||
const char* session_trx_state_to_string(mxs_session_trx_state_t state);
|
typedef struct
|
||||||
|
|
||||||
/**
|
|
||||||
* The downstream element in the filter chain. This may refer to
|
|
||||||
* another filter or to a router.
|
|
||||||
*/
|
|
||||||
typedef struct mxs_downstream
|
|
||||||
{
|
{
|
||||||
void *instance;
|
time_t connect; /**< Time when the session was started */
|
||||||
void *session;
|
} MXS_SESSION_STATS;
|
||||||
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}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Structure used to track the filter instances and sessions of the filters
|
* Structure used to track the filter instances and sessions of the filters
|
||||||
@ -137,16 +85,28 @@ typedef struct
|
|||||||
void *session;
|
void *session;
|
||||||
} SESSION_FILTER;
|
} 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,
|
void *instance;
|
||||||
SESSION_LIST_CONNECTION
|
void *session;
|
||||||
} SESSIONLISTFILTER;
|
int32_t (*clientReply)(void *instance, void *session, GWBUF *response);
|
||||||
|
int32_t (*error)(void *instance, void *session, void *);
|
||||||
|
} MXS_UPSTREAM;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The session status block
|
* The session status block
|
||||||
@ -167,7 +127,7 @@ typedef struct session
|
|||||||
int enabled_log_priorities; /*< Bitfield of enabled syslog priorities */
|
int enabled_log_priorities; /*< Bitfield of enabled syslog priorities */
|
||||||
struct dcb *client_dcb; /*< The client connection */
|
struct dcb *client_dcb; /*< The client connection */
|
||||||
void *router_session; /*< The router instance data */
|
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 */
|
struct service *service; /*< The service this session is using */
|
||||||
int n_filters; /*< Number of filter sessions */
|
int n_filters; /*< Number of filter sessions */
|
||||||
SESSION_FILTER *filters; /*< The filters in use within this session */
|
SESSION_FILTER *filters; /*< The filters in use within this session */
|
||||||
@ -185,12 +145,6 @@ typedef struct session
|
|||||||
skygw_chk_t ses_chk_tail;
|
skygw_chk_t ses_chk_tail;
|
||||||
} MXS_SESSION;
|
} 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
|
* 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
|
* 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_alloc(struct service *, struct dcb *);
|
||||||
MXS_SESSION *session_set_dummy(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_remote(const MXS_SESSION *);
|
||||||
const char *session_get_user(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_enable_log_priority(MXS_SESSION* ses, int priority);
|
||||||
void session_disable_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.
|
* 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);
|
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
|
* @brief Release a session reference
|
||||||
*
|
*
|
||||||
|
* This function is public only because the tee-filter uses it.
|
||||||
|
*
|
||||||
* @param session Session reference to release
|
* @param session Session reference to release
|
||||||
*/
|
*/
|
||||||
void session_put_ref(MXS_SESSION *session);
|
void session_put_ref(MXS_SESSION *session);
|
||||||
|
|||||||
@ -63,20 +63,21 @@
|
|||||||
*
|
*
|
||||||
* @endverbatim
|
* @endverbatim
|
||||||
*/
|
*/
|
||||||
#include <stdio.h>
|
#include <maxscale/dcb.h>
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <maxscale/dcb.h>
|
#include <time.h>
|
||||||
|
|
||||||
#include <maxscale/spinlock.h>
|
#include <maxscale/spinlock.h>
|
||||||
#include <maxscale/server.h>
|
#include <maxscale/server.h>
|
||||||
#include <maxscale/session.h>
|
|
||||||
#include <maxscale/service.h>
|
#include <maxscale/service.h>
|
||||||
#include <maxscale/modules.h>
|
#include <maxscale/modules.h>
|
||||||
#include <maxscale/router.h>
|
#include <maxscale/router.h>
|
||||||
#include <errno.h>
|
|
||||||
#include <maxscale/poll.h>
|
#include <maxscale/poll.h>
|
||||||
#include <maxscale/atomic.h>
|
#include <maxscale/atomic.h>
|
||||||
#include <maxscale/log_manager.h>
|
#include <maxscale/log_manager.h>
|
||||||
@ -93,6 +94,8 @@
|
|||||||
#include <maxscale/utils.h>
|
#include <maxscale/utils.h>
|
||||||
#include <maxscale/platform.h>
|
#include <maxscale/platform.h>
|
||||||
|
|
||||||
|
#include "maxscale/session.h"
|
||||||
|
|
||||||
/* A DCB with null values, used for initialization */
|
/* A DCB with null values, used for initialization */
|
||||||
static DCB dcb_initialized = DCB_INIT;
|
static DCB dcb_initialized = DCB_INIT;
|
||||||
|
|
||||||
|
|||||||
71
server/core/maxscale/session.h
Normal file
71
server/core/maxscale/session.h
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
#pragma once
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2016 MariaDB Corporation Ab
|
||||||
|
*
|
||||||
|
* Use of this software is governed by the Business Source License included
|
||||||
|
* in the LICENSE.TXT file and at www.mariadb.com/bsl.
|
||||||
|
*
|
||||||
|
* Change Date: 2019-07-01
|
||||||
|
*
|
||||||
|
* On the date above, in accordance with the Business Source License, use
|
||||||
|
* of this software will be governed by version 2 or later of the General
|
||||||
|
* Public License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file core/maxscale/session.h - The private session interface
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <maxscale/session.h>
|
||||||
|
|
||||||
|
MXS_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define SESSION_STATS_INIT {0}
|
||||||
|
#define MXS_DOWNSTREAM_INIT {0}
|
||||||
|
#define MXS_UPSTREAM_INIT {0}
|
||||||
|
#define SESSION_FILTER_INIT {0}
|
||||||
|
|
||||||
|
#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)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter type for the sessionGetList call
|
||||||
|
*/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
SESSION_LIST_ALL,
|
||||||
|
SESSION_LIST_CONNECTION
|
||||||
|
} SESSIONLISTFILTER;
|
||||||
|
|
||||||
|
int session_isvalid(MXS_SESSION *);
|
||||||
|
int session_reply(void *inst, void *session, GWBUF *data);
|
||||||
|
char *session_state(mxs_session_state_t);
|
||||||
|
bool session_link_dcb(MXS_SESSION *, struct dcb *);
|
||||||
|
|
||||||
|
RESULTSET *sessionGetList(SESSIONLISTFILTER);
|
||||||
|
|
||||||
|
void printAllSessions();
|
||||||
|
void printSession(MXS_SESSION *);
|
||||||
|
|
||||||
|
void dprintSessionList(DCB *pdcb);
|
||||||
|
void dprintAllSessions(struct dcb *);
|
||||||
|
void dprintSession(struct dcb *, MXS_SESSION *);
|
||||||
|
void dListSessions(struct dcb *);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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);
|
||||||
|
|
||||||
|
MXS_END_DECLS
|
||||||
@ -28,11 +28,13 @@
|
|||||||
* @endverbatim
|
* @endverbatim
|
||||||
*/
|
*/
|
||||||
#include <maxscale/session.h>
|
#include <maxscale/session.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include <maxscale/alloc.h>
|
#include <maxscale/alloc.h>
|
||||||
#include <maxscale/atomic.h>
|
#include <maxscale/atomic.h>
|
||||||
#include <maxscale/dcb.h>
|
#include <maxscale/dcb.h>
|
||||||
@ -42,6 +44,8 @@
|
|||||||
#include <maxscale/router.h>
|
#include <maxscale/router.h>
|
||||||
#include <maxscale/service.h>
|
#include <maxscale/service.h>
|
||||||
#include <maxscale/spinlock.h>
|
#include <maxscale/spinlock.h>
|
||||||
|
|
||||||
|
#include "maxscale/session.h"
|
||||||
#include "maxscale/filter.h"
|
#include "maxscale/filter.h"
|
||||||
|
|
||||||
/* A session with null values, used for initialization */
|
/* A session with null values, used for initialization */
|
||||||
@ -230,7 +234,7 @@ session_set_dummy(DCB *client_dcb)
|
|||||||
session->service = NULL;
|
session->service = NULL;
|
||||||
session->client_dcb = NULL;
|
session->client_dcb = NULL;
|
||||||
session->n_filters = 0;
|
session->n_filters = 0;
|
||||||
memset(&session->stats, 0, sizeof(SESSION_STATS));
|
memset(&session->stats, 0, sizeof(MXS_SESSION_STATS));
|
||||||
session->stats.connect = 0;
|
session->stats.connect = 0;
|
||||||
session->state = SESSION_STATE_DUMMY;
|
session->state = SESSION_STATE_DUMMY;
|
||||||
session->refcount = 1;
|
session->refcount = 1;
|
||||||
@ -688,7 +692,7 @@ session_setup_filters(MXS_SESSION *session)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Entry point for the final element int he upstream filter, i.e. the writing
|
* Entry point for the final element in the upstream filter, i.e. the writing
|
||||||
* of the data to the client.
|
* of the data to the client.
|
||||||
*
|
*
|
||||||
* @param instance The "instance" data
|
* @param instance The "instance" data
|
||||||
|
|||||||
@ -53,7 +53,6 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <maxscale/alloc.h>
|
#include <maxscale/alloc.h>
|
||||||
#include <maxscale/service.h>
|
#include <maxscale/service.h>
|
||||||
#include <maxscale/session.h>
|
|
||||||
#include <maxscale/router.h>
|
#include <maxscale/router.h>
|
||||||
#include <maxscale/filter.h>
|
#include <maxscale/filter.h>
|
||||||
#include <maxscale/modules.h>
|
#include <maxscale/modules.h>
|
||||||
@ -78,6 +77,8 @@
|
|||||||
#include <maxscale/log_manager.h>
|
#include <maxscale/log_manager.h>
|
||||||
#include <sys/syslog.h>
|
#include <sys/syslog.h>
|
||||||
|
|
||||||
|
#include "../../../core/maxscale/session.h"
|
||||||
|
|
||||||
#define MAXARGS 12
|
#define MAXARGS 12
|
||||||
|
|
||||||
#define ARG_TYPE_NONE 0
|
#define ARG_TYPE_NONE 0
|
||||||
|
|||||||
@ -34,7 +34,6 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <maxscale/alloc.h>
|
#include <maxscale/alloc.h>
|
||||||
#include <maxscale/service.h>
|
#include <maxscale/service.h>
|
||||||
#include <maxscale/session.h>
|
|
||||||
#include <maxscale/server.h>
|
#include <maxscale/server.h>
|
||||||
#include <maxscale/router.h>
|
#include <maxscale/router.h>
|
||||||
#include <maxscale/modules.h>
|
#include <maxscale/modules.h>
|
||||||
@ -53,6 +52,8 @@
|
|||||||
#include <maxscale/secrets.h>
|
#include <maxscale/secrets.h>
|
||||||
#include <maxscale/users.h>
|
#include <maxscale/users.h>
|
||||||
|
|
||||||
|
#include "../../../core/maxscale/session.h"
|
||||||
|
|
||||||
extern char *create_hex_sha1_sha1_passwd(char *passwd);
|
extern char *create_hex_sha1_sha1_passwd(char *passwd);
|
||||||
|
|
||||||
static int maxinfo_statistics(INFO_INSTANCE *, INFO_SESSION *, GWBUF *);
|
static int maxinfo_statistics(INFO_INSTANCE *, INFO_SESSION *, GWBUF *);
|
||||||
|
|||||||
@ -31,7 +31,6 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <maxscale/alloc.h>
|
#include <maxscale/alloc.h>
|
||||||
#include <maxscale/service.h>
|
#include <maxscale/service.h>
|
||||||
#include <maxscale/session.h>
|
|
||||||
#include <maxscale/router.h>
|
#include <maxscale/router.h>
|
||||||
#include <maxscale/modules.h>
|
#include <maxscale/modules.h>
|
||||||
#include <maxscale/monitor.h>
|
#include <maxscale/monitor.h>
|
||||||
@ -47,6 +46,8 @@
|
|||||||
#include <maxscale/resultset.h>
|
#include <maxscale/resultset.h>
|
||||||
#include <maxscale/config.h>
|
#include <maxscale/config.h>
|
||||||
|
|
||||||
|
#include "../../../core/maxscale/session.h"
|
||||||
|
|
||||||
static void exec_show(DCB *dcb, MAXINFO_TREE *tree);
|
static void exec_show(DCB *dcb, MAXINFO_TREE *tree);
|
||||||
static void exec_select(DCB *dcb, MAXINFO_TREE *tree);
|
static void exec_select(DCB *dcb, MAXINFO_TREE *tree);
|
||||||
static void exec_show_variables(DCB *dcb, MAXINFO_TREE *filter);
|
static void exec_show_variables(DCB *dcb, MAXINFO_TREE *filter);
|
||||||
|
|||||||
Reference in New Issue
Block a user