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

@ -63,20 +63,21 @@
*
* @endverbatim
*/
#include <stdio.h>
#include <maxscale/dcb.h>
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <signal.h>
#include <maxscale/dcb.h>
#include <time.h>
#include <maxscale/spinlock.h>
#include <maxscale/server.h>
#include <maxscale/session.h>
#include <maxscale/service.h>
#include <maxscale/modules.h>
#include <maxscale/router.h>
#include <errno.h>
#include <maxscale/poll.h>
#include <maxscale/atomic.h>
#include <maxscale/log_manager.h>
@ -93,6 +94,8 @@
#include <maxscale/utils.h>
#include <maxscale/platform.h>
#include "maxscale/session.h"
/* A DCB with null values, used for initialization */
static DCB dcb_initialized = DCB_INIT;

View 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

View File

@ -28,11 +28,13 @@
* @endverbatim
*/
#include <maxscale/session.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <maxscale/alloc.h>
#include <maxscale/atomic.h>
#include <maxscale/dcb.h>
@ -42,6 +44,8 @@
#include <maxscale/router.h>
#include <maxscale/service.h>
#include <maxscale/spinlock.h>
#include "maxscale/session.h"
#include "maxscale/filter.h"
/* A session with null values, used for initialization */
@ -230,7 +234,7 @@ session_set_dummy(DCB *client_dcb)
session->service = NULL;
session->client_dcb = NULL;
session->n_filters = 0;
memset(&session->stats, 0, sizeof(SESSION_STATS));
memset(&session->stats, 0, sizeof(MXS_SESSION_STATS));
session->stats.connect = 0;
session->state = SESSION_STATE_DUMMY;
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.
*
* @param instance The "instance" data

View File

@ -53,7 +53,6 @@
#include <errno.h>
#include <maxscale/alloc.h>
#include <maxscale/service.h>
#include <maxscale/session.h>
#include <maxscale/router.h>
#include <maxscale/filter.h>
#include <maxscale/modules.h>
@ -78,6 +77,8 @@
#include <maxscale/log_manager.h>
#include <sys/syslog.h>
#include "../../../core/maxscale/session.h"
#define MAXARGS 12
#define ARG_TYPE_NONE 0

View File

@ -34,7 +34,6 @@
#include <time.h>
#include <maxscale/alloc.h>
#include <maxscale/service.h>
#include <maxscale/session.h>
#include <maxscale/server.h>
#include <maxscale/router.h>
#include <maxscale/modules.h>
@ -53,6 +52,8 @@
#include <maxscale/secrets.h>
#include <maxscale/users.h>
#include "../../../core/maxscale/session.h"
extern char *create_hex_sha1_sha1_passwd(char *passwd);
static int maxinfo_statistics(INFO_INSTANCE *, INFO_SESSION *, GWBUF *);

View File

@ -31,7 +31,6 @@
#include <string.h>
#include <maxscale/alloc.h>
#include <maxscale/service.h>
#include <maxscale/session.h>
#include <maxscale/router.h>
#include <maxscale/modules.h>
#include <maxscale/monitor.h>
@ -47,6 +46,8 @@
#include <maxscale/resultset.h>
#include <maxscale/config.h>
#include "../../../core/maxscale/session.h"
static void exec_show(DCB *dcb, MAXINFO_TREE *tree);
static void exec_select(DCB *dcb, MAXINFO_TREE *tree);
static void exec_show_variables(DCB *dcb, MAXINFO_TREE *filter);