diff options
| author | Fabiano FidĂȘncio <fidencio@redhat.com> | 2017-03-02 17:36:02 +0100 |
|---|---|---|
| committer | Jakub Hrozek <jhrozek@redhat.com> | 2017-03-08 12:33:04 +0100 |
| commit | ef268f9e691b0953763fad7e66f0724bed9b3419 (patch) | |
| tree | 0d476b1fb1edd51967088c1e2426962b7fa4b0fe /src/responder/common | |
| parent | 0dacb781f094b97e40694aeff288853a8a4e9d63 (diff) | |
| download | sssd-ef268f9e691b0953763fad7e66f0724bed9b3419.tar.gz sssd-ef268f9e691b0953763fad7e66f0724bed9b3419.tar.xz sssd-ef268f9e691b0953763fad7e66f0724bed9b3419.zip | |
RESPONDER: Wrap up the code to setup the idle timeout
As secrets responder will make use of this very same code in the future,
let's wrap it up into a new function in order to avoid code duplication.
Related:
https://pagure.io/SSSD/sssd/issue/3316
Signed-off-by: Fabiano FidĂȘncio <fidencio@redhat.com>
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
Reviewed-by: Fabiano FidĂȘncio <fidencio@redhat.com>
Diffstat (limited to 'src/responder/common')
| -rw-r--r-- | src/responder/common/responder.h | 2 | ||||
| -rw-r--r-- | src/responder/common/responder_common.c | 87 |
2 files changed, 54 insertions, 35 deletions
diff --git a/src/responder/common/responder.h b/src/responder/common/responder.h index 3515f76d2..5717d6a82 100644 --- a/src/responder/common/responder.h +++ b/src/responder/common/responder.h @@ -344,6 +344,8 @@ void responder_set_fd_limit(rlim_t fd_limit); errno_t reset_client_idle_timer(struct cli_ctx *cctx); +errno_t responder_setup_idle_timeout_config(struct resp_ctx *rctx); + #define GET_DOMAINS_DEFAULT_TIMEOUT 60 struct tevent_req *sss_dp_get_domains_send(TALLOC_CTX *mem_ctx, diff --git a/src/responder/common/responder_common.c b/src/responder/common/responder_common.c index 1959247ff..5c59f0d8f 100644 --- a/src/responder/common/responder_common.c +++ b/src/responder/common/responder_common.c @@ -1095,44 +1095,10 @@ int sss_process_init(TALLOC_CTX *mem_ctx, } if (rctx->socket_activated || rctx->dbus_activated) { - ret = confdb_get_int(rctx->cdb, rctx->confdb_service_path, - CONFDB_RESPONDER_IDLE_TIMEOUT, - CONFDB_RESPONDER_IDLE_DEFAULT_TIMEOUT, - &rctx->idle_timeout); + ret = responder_setup_idle_timeout_config(rctx); if (ret != EOK) { - DEBUG(SSSDBG_OP_FAILURE, - "Cannot get the responder idle timeout [%d]: %s\n", - ret, sss_strerror(ret)); goto fail; } - - /* Idle timeout set to 0 means that no timeout will be set up to - * the responder */ - if (rctx->idle_timeout == 0) { - DEBUG(SSSDBG_TRACE_INTERNAL, - "Responder idle timeout won't be set up as the " - "responder_idle_timeout is set to 0"); - } else { - /* Ensure that the responder timeout is at least sixty seconds */ - if (rctx->idle_timeout < 60) { - DEBUG(SSSDBG_TRACE_INTERNAL, - "responder_idle_timeout is set to a value lower than " - "the minimum allowed (60s).\n" - "The minimum allowed value will be used."); - - rctx->idle_timeout = 60; - } - - ret = setup_responder_idle_timer(rctx); - if (ret != EOK) { - DEBUG(SSSDBG_MINOR_FAILURE, - "An error ocurrend when setting up the responder's idle " - "timeout for the responder [%p]: %s [%d].\n" - "The responder won't be automatically shutdown after %d " - "seconds inactive. \n", - rctx, sss_strerror(ret), ret, rctx->idle_timeout); - } - } } ret = confdb_get_int(rctx->cdb, rctx->confdb_service_path, @@ -1425,3 +1391,54 @@ void responder_set_fd_limit(rlim_t fd_limit) "Proceeding with system values\n"); } } + +errno_t responder_setup_idle_timeout_config(struct resp_ctx *rctx) +{ + errno_t ret; + + ret = confdb_get_int(rctx->cdb, rctx->confdb_service_path, + CONFDB_RESPONDER_IDLE_TIMEOUT, + CONFDB_RESPONDER_IDLE_DEFAULT_TIMEOUT, + &rctx->idle_timeout); + if (ret != EOK) { + DEBUG(SSSDBG_OP_FAILURE, + "Cannot get the responder idle timeout [%d]: %s\n", + ret, sss_strerror(ret)); + goto fail; + } + + /* Idle timeout set to 0 means that no timeout will be set up to + * the responder */ + if (rctx->idle_timeout == 0) { + DEBUG(SSSDBG_TRACE_INTERNAL, + "Responder idle timeout won't be set up as the " + "responder_idle_timeout is set to 0"); + } else { + /* Ensure that the responder timeout is at least sixty seconds */ + if (rctx->idle_timeout < 60) { + DEBUG(SSSDBG_TRACE_INTERNAL, + "responder_idle_timeout is set to a value lower than " + "the minimum allowed (60s).\n" + "The minimum allowed value will be used."); + + rctx->idle_timeout = 60; + } + + ret = setup_responder_idle_timer(rctx); + if (ret != EOK) { + DEBUG(SSSDBG_MINOR_FAILURE, + "An error ocurrend when setting up the responder's idle " + "timeout for the responder [%p]: %s [%d].\n" + "The responder won't be automatically shutdown after %d " + "seconds inactive. \n", + rctx, sss_strerror(ret), ret, + rctx->idle_timeout); + } + } + + ret = EOK; + +fail: + return ret; + +} |
