From 26dfb19ea4a888a121b09806156de1c43f5ef68b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Thu, 30 Aug 2018 03:21:21 +0300 Subject: [PATCH] Make routingworker.hh public Given that worker.hh was public, it made sense to make routingworker.hh public as well. This removes the need to include private headers in modules and allows C++ constructs to be used in C++ code when previously only the C API was available. --- .../maxscale}/routingworker.hh | 4 +- include/maxscale/session.hh | 38 +++++++++++++++++++ server/core/dcb.cc | 2 +- server/core/gateway.cc | 2 +- server/core/internal/session.hh | 19 +--------- server/core/misc.cc | 3 +- server/core/poll.cc | 3 +- server/core/resource.cc | 2 +- server/core/routingworker.cc | 2 +- server/core/server.cc | 2 +- server/core/service.cc | 2 +- server/core/session.cc | 4 +- server/core/test/test_dcb.cc | 2 +- server/core/test/test_utils.h | 2 +- .../modules/protocol/MySQL/mariadb_client.cc | 4 +- server/modules/routing/debugcli/debugcmd.cc | 2 +- 16 files changed, 58 insertions(+), 35 deletions(-) rename {server/core/internal => include/maxscale}/routingworker.hh (99%) create mode 100644 include/maxscale/session.hh diff --git a/server/core/internal/routingworker.hh b/include/maxscale/routingworker.hh similarity index 99% rename from server/core/internal/routingworker.hh rename to include/maxscale/routingworker.hh index 5dfeb1f2b..b8dda0e64 100644 --- a/server/core/internal/routingworker.hh +++ b/include/maxscale/routingworker.hh @@ -15,14 +15,16 @@ #include #include +#include +#include #include #include #include #include #include +#include -#include "session.hh" namespace maxscale { diff --git a/include/maxscale/session.hh b/include/maxscale/session.hh new file mode 100644 index 000000000..e50167356 --- /dev/null +++ b/include/maxscale/session.hh @@ -0,0 +1,38 @@ +/* + * 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 + +#include + +namespace maxscale +{ +/** + * Specialization of RegistryTraits for the session registry. + */ +template<> +struct RegistryTraits +{ + typedef uint64_t id_type; + typedef MXS_SESSION* entry_type; + + static id_type get_id(entry_type entry) + { + return entry->ses_id; + } + static entry_type null_entry() + { + return NULL; + } +}; + +} diff --git a/server/core/dcb.cc b/server/core/dcb.cc index 974ed679e..12333d327 100644 --- a/server/core/dcb.cc +++ b/server/core/dcb.cc @@ -51,9 +51,9 @@ #include #include #include +#include #include "internal/modules.h" -#include "internal/routingworker.hh" #include "internal/session.h" using maxscale::RoutingWorker; diff --git a/server/core/gateway.cc b/server/core/gateway.cc index 67688af04..cab84dd32 100644 --- a/server/core/gateway.cc +++ b/server/core/gateway.cc @@ -58,6 +58,7 @@ #include #include #include +#include #include "internal/admin.hh" #include "internal/config.hh" @@ -65,7 +66,6 @@ #include "internal/modules.h" #include "internal/monitor.h" #include "internal/poll.hh" -#include "internal/routingworker.hh" #include "internal/service.hh" #include "internal/statistics.h" diff --git a/server/core/internal/session.hh b/server/core/internal/session.hh index ab6e27964..235607f55 100644 --- a/server/core/internal/session.hh +++ b/server/core/internal/session.hh @@ -26,27 +26,10 @@ #include "filter.hh" #include "service.hh" +#include "session.h" namespace maxscale { -/** - * Specialization of RegistryTraits for the session registry. - */ -template<> -struct RegistryTraits -{ - typedef uint64_t id_type; - typedef MXS_SESSION* entry_type; - - static id_type get_id(entry_type entry) - { - return entry->ses_id; - } - static entry_type null_entry() - { - return NULL; - } -}; typedef struct SESSION_VARIABLE { diff --git a/server/core/misc.cc b/server/core/misc.cc index 2037f2c07..2098ad95c 100644 --- a/server/core/misc.cc +++ b/server/core/misc.cc @@ -15,8 +15,9 @@ #include +#include + #include "internal/maxscale.h" -#include "internal/routingworker.hh" #include "internal/service.hh" static time_t started; diff --git a/server/core/poll.cc b/server/core/poll.cc index 864cfc4b1..1a2ee669e 100644 --- a/server/core/poll.cc +++ b/server/core/poll.cc @@ -34,8 +34,9 @@ #include #include #include +#include + #include "internal/poll.hh" -#include "internal/routingworker.hh" using maxbase::Worker; using maxscale::RoutingWorker; diff --git a/server/core/resource.cc b/server/core/resource.cc index 6216e8122..fd0a52204 100644 --- a/server/core/resource.cc +++ b/server/core/resource.cc @@ -25,6 +25,7 @@ #include #include #include +#include #include "internal/config_runtime.h" #include "internal/filter.hh" @@ -33,7 +34,6 @@ #include "internal/modules.h" #include "internal/monitor.h" #include "internal/query_classifier.hh" -#include "internal/routingworker.hh" #include "internal/service.hh" #include "internal/session.h" diff --git a/server/core/routingworker.cc b/server/core/routingworker.cc index f3cad665c..c4a0dd06f 100644 --- a/server/core/routingworker.cc +++ b/server/core/routingworker.cc @@ -11,7 +11,7 @@ * Public License. */ -#include "internal/routingworker.hh" +#include #include #include diff --git a/server/core/server.cc b/server/core/server.cc index cff8b7866..0dd825238 100644 --- a/server/core/server.cc +++ b/server/core/server.cc @@ -45,10 +45,10 @@ #include #include #include +#include #include "internal/monitor.h" #include "internal/poll.hh" -#include "internal/routingworker.hh" #include "internal/config.hh" #include "internal/service.hh" #include "internal/modules.h" diff --git a/server/core/service.cc b/server/core/service.cc index a51b78da6..a03223ec5 100644 --- a/server/core/service.cc +++ b/server/core/service.cc @@ -53,12 +53,12 @@ #include #include #include +#include #include "internal/config.hh" #include "internal/filter.hh" #include "internal/modules.h" #include "internal/service.hh" -#include "internal/routingworker.hh" #include "internal/maxscale.h" /** This define is needed in CentOS 6 systems */ diff --git a/server/core/session.cc b/server/core/session.cc index d35298e84..2abeefaca 100644 --- a/server/core/session.cc +++ b/server/core/session.cc @@ -39,11 +39,11 @@ #include #include #include +#include #include "internal/dcb.h" #include "internal/filter.hh" -#include "internal/routingworker.hh" -#include "internal/session.h" +#include "internal/session.hh" #include "internal/service.hh" using std::string; diff --git a/server/core/test/test_dcb.cc b/server/core/test/test_dcb.cc index ef9d91595..773040a99 100644 --- a/server/core/test/test_dcb.cc +++ b/server/core/test/test_dcb.cc @@ -36,8 +36,8 @@ #include #include +#include -#include "../internal/routingworker.hh" #include "../dcb.cc" #include "test_utils.h" diff --git a/server/core/test/test_utils.h b/server/core/test/test_utils.h index 8820f665f..3ddbc30af 100644 --- a/server/core/test/test_utils.h +++ b/server/core/test/test_utils.h @@ -24,11 +24,11 @@ #include #include #include +#include #include #include "../internal/poll.hh" -#include "../internal/routingworker.hh" #include "../internal/statistics.h" diff --git a/server/modules/protocol/MySQL/mariadb_client.cc b/server/modules/protocol/MySQL/mariadb_client.cc index ccd8c0e71..cc61050ed 100644 --- a/server/modules/protocol/MySQL/mariadb_client.cc +++ b/server/modules/protocol/MySQL/mariadb_client.cc @@ -12,11 +12,9 @@ */ #include +#include #include -// TODO: Find a way to cleanly expose this -#include "../../../core/internal/routingworker.hh" - #ifdef EPOLLRDHUP #define ERROR_EVENTS (EPOLLRDHUP | EPOLLHUP | EPOLLERR) #else diff --git a/server/modules/routing/debugcli/debugcmd.cc b/server/modules/routing/debugcli/debugcmd.cc index ae98ae2a6..a8c3093c5 100644 --- a/server/modules/routing/debugcli/debugcmd.cc +++ b/server/modules/routing/debugcli/debugcmd.cc @@ -54,6 +54,7 @@ #include #include #include +#include #include @@ -65,7 +66,6 @@ #include "../../../core/internal/poll.hh" #include "../../../core/internal/session.h" #include "../../../core/internal/filter.hh" -#include "../../../core/internal/routingworker.hh" #define MAXARGS 14