From 9fb4116bf5bbdc7cae3fe3a437c722d086b737ab Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Mon, 29 Apr 2019 10:49:26 +0300 Subject: [PATCH] MXS-2329 Use durations with connection_timeout --- Documentation/Getting-Started/Configuration-Guide.md | 8 +++++++- server/core/config.cc | 5 +++-- server/core/service.cc | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Documentation/Getting-Started/Configuration-Guide.md b/Documentation/Getting-Started/Configuration-Guide.md index fb5177a7d..0af6e5886 100644 --- a/Documentation/Getting-Started/Configuration-Guide.md +++ b/Documentation/Getting-Started/Configuration-Guide.md @@ -1401,6 +1401,12 @@ default. To enable them, define the timeout in seconds in the service's configuration section. A value of zero is interpreted as no timeout, the same as if the parameter is not defined. +The value is specified as documented [here](#durations). If no explicit unit +is provided, the value is interpreted as seconds in MaxScale 2.4. In subsequent +versions a value without a unit may be rejected. Note that since the granularity +of the timeout is seconds, a timeout specified in milliseconds will be rejected, +even if the duration is longer than a second. + **Warning:** If a connection is idle for longer than the configured connection timeout, it will be forcefully disconnected and a warning will be logged in the MaxScale log file. If you are performing long-running maintenance operations @@ -1411,7 +1417,7 @@ Example: ``` [Test-Service] -connection_timeout=300 +connection_timeout=300s ``` #### `max_connections` diff --git a/server/core/config.cc b/server/core/config.cc index d84e30277..b7e89949e 100644 --- a/server/core/config.cc +++ b/server/core/config.cc @@ -336,8 +336,9 @@ const MXS_MODULE_PARAM config_service_params[] = }, { CN_CONNECTION_TIMEOUT, - MXS_MODULE_PARAM_COUNT, - "0" + MXS_MODULE_PARAM_DURATION, + "0", + MXS_MODULE_OPT_DURATION_S }, { CN_AUTH_ALL_SERVERS, diff --git a/server/core/service.cc b/server/core/service.cc index 4da3ad9f1..173fa5c75 100644 --- a/server/core/service.cc +++ b/server/core/service.cc @@ -219,7 +219,7 @@ Service::Service(const std::string& name, localhost_match_wildcard_host = params->get_bool(CN_LOCALHOST_MATCH_WILDCARD_HOST); retry_start = params->get_bool(CN_RETRY_ON_FAILURE); enable_root = params->get_bool(CN_ENABLE_ROOT_USER); - conn_idle_timeout = params->get_integer(CN_CONNECTION_TIMEOUT); + conn_idle_timeout = params->get_duration(CN_CONNECTION_TIMEOUT).count(); max_connections = params->get_integer(CN_MAX_CONNECTIONS); log_auth_warnings = params->get_bool(CN_LOG_AUTH_WARNINGS); strip_db_esc = params->get_bool(CN_STRIP_DB_ESC);