From cdf323384c5ca05a3caa06a3d230f8cf08fbc174 Mon Sep 17 00:00:00 2001 From: Esa Korhonen Date: Fri, 30 Nov 2018 18:47:43 +0200 Subject: [PATCH] MXS-2205 Combine internal/session.h with internal/session.hh --- include/maxscale/session.hh | 2 + server/core/dcb.cc | 2 +- server/core/internal/resource.hh | 2 +- server/core/internal/session.h | 84 --------------------- server/core/internal/session.hh | 68 ++++++++++++++++- server/core/resource.cc | 2 +- server/modules/routing/debugcli/debugcmd.cc | 2 +- server/modules/routing/maxinfo/maxinfo.cc | 1 - 8 files changed, 72 insertions(+), 91 deletions(-) delete mode 100644 server/core/internal/session.h diff --git a/include/maxscale/session.hh b/include/maxscale/session.hh index 2dd65ed1a..a4f46705b 100644 --- a/include/maxscale/session.hh +++ b/include/maxscale/session.hh @@ -12,7 +12,9 @@ */ #pragma once +#include #include +#include namespace maxscale { diff --git a/server/core/dcb.cc b/server/core/dcb.cc index 85ce34763..29ad3f68d 100644 --- a/server/core/dcb.cc +++ b/server/core/dcb.cc @@ -53,7 +53,7 @@ #include #include "internal/modules.hh" -#include "internal/session.h" +#include "internal/session.hh" using maxscale::RoutingWorker; using maxbase::Worker; diff --git a/server/core/internal/resource.hh b/server/core/internal/resource.hh index ab5253b32..65878f982 100644 --- a/server/core/internal/resource.hh +++ b/server/core/internal/resource.hh @@ -27,7 +27,7 @@ #include "monitor.hh" #include "service.hh" #include "filter.hh" -#include "session.h" +#include "session.hh" typedef HttpResponse (* ResourceCallback)(const HttpRequest& request); diff --git a/server/core/internal/session.h b/server/core/internal/session.h deleted file mode 100644 index b6797ce58..000000000 --- a/server/core/internal/session.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2018 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/bsl11. - * - * Change Date: 2022-01-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. - */ -#pragma once - -/** - * @file core/maxscale/session.h - The private session interface - */ - -#include - -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, \ - .stats = SESSION_STATS_INIT, .head = MXS_DOWNSTREAM_INIT, .tail = MXS_UPSTREAM_INIT, \ - .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) - -/** - * Filter type for the sessionGetList call - */ -typedef enum -{ - SESSION_LIST_ALL, - SESSION_LIST_CONNECTION -} SESSIONLISTFILTER; - -int session_isvalid(MXS_SESSION*); -const char* session_state(mxs_session_state_t); - -/** - * Link a session to a backend DCB. - * - * @param session The session to link with the dcb - * @param dcb The backend DCB to be linked - */ -void session_link_backend_dcb(MXS_SESSION* session, struct dcb* dcb); - -/** - * Unlink a session to a backend DCB. - * - * @param session The session to unlink with the dcb - * @param dcb The backend DCB to be unlinked - */ -void session_unlink_backend_dcb(MXS_SESSION* session, struct dcb* dcb); - -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 diff --git a/server/core/internal/session.hh b/server/core/internal/session.hh index 1a5fb9fff..c759aeadf 100644 --- a/server/core/internal/session.hh +++ b/server/core/internal/session.hh @@ -21,13 +21,77 @@ #include #include -#include +#include #include #include #include "filter.hh" #include "service.hh" -#include "session.h" + +#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, \ + .stats = SESSION_STATS_INIT, .head = MXS_DOWNSTREAM_INIT, .tail = MXS_UPSTREAM_INIT, \ + .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) + +MXS_BEGIN_DECLS + +/** + * Filter type for the sessionGetList call + */ +typedef enum +{ + SESSION_LIST_ALL, + SESSION_LIST_CONNECTION +} SESSIONLISTFILTER; + +int session_isvalid(MXS_SESSION*); +const char* session_state(mxs_session_state_t); + +/** + * Link a session to a backend DCB. + * + * @param session The session to link with the dcb + * @param dcb The backend DCB to be linked + */ +void session_link_backend_dcb(MXS_SESSION* session, struct dcb* dcb); + +/** + * Unlink a session to a backend DCB. + * + * @param session The session to unlink with the dcb + * @param dcb The backend DCB to be unlinked + */ +void session_unlink_backend_dcb(MXS_SESSION* session, struct dcb* dcb); + +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 namespace maxscale { diff --git a/server/core/resource.cc b/server/core/resource.cc index 7fd1711fb..46ab9ef0c 100644 --- a/server/core/resource.cc +++ b/server/core/resource.cc @@ -34,7 +34,7 @@ #include "internal/monitor.hh" #include "internal/query_classifier.hh" #include "internal/service.hh" -#include "internal/session.h" +#include "internal/session.hh" using std::list; using std::map; diff --git a/server/modules/routing/debugcli/debugcmd.cc b/server/modules/routing/debugcli/debugcmd.cc index 228a56dc8..2c1877b11 100644 --- a/server/modules/routing/debugcli/debugcmd.cc +++ b/server/modules/routing/debugcli/debugcmd.cc @@ -62,7 +62,7 @@ #include "../../../core/internal/modules.hh" #include "../../../core/internal/monitor.hh" #include "../../../core/internal/poll.hh" -#include "../../../core/internal/session.h" +#include "../../../core/internal/session.hh" #include "../../../core/internal/filter.hh" #define MAXARGS 14 diff --git a/server/modules/routing/maxinfo/maxinfo.cc b/server/modules/routing/maxinfo/maxinfo.cc index e784b0e4d..e29678963 100644 --- a/server/modules/routing/maxinfo/maxinfo.cc +++ b/server/modules/routing/maxinfo/maxinfo.cc @@ -53,7 +53,6 @@ #include "../../../core/internal/modules.hh" #include "../../../core/internal/monitor.hh" -#include "../../../core/internal/session.h" #include "../../../core/internal/session.hh" #include "../../../core/internal/poll.hh"