diff options
author | Jakub Hrozek <[email protected]> | 2017-07-11 18:26:01 +0200 |
---|---|---|
committer | Lukas Slebodnik <[email protected]> | 2017-07-21 19:41:24 +0200 |
commit | 422217c7ea5fbe94b386c93c19e2c1928151faa0 (patch) | |
tree | 797a94d9c8d394221c02c7f5482bbeb80e23ebb3 | |
parent | d67a89931c651a0c757e9b890b50700170d59a88 (diff) | |
download | sssd-422217c7ea5fbe94b386c93c19e2c1928151faa0.tar.gz sssd-422217c7ea5fbe94b386c93c19e2c1928151faa0.tar.xz sssd-422217c7ea5fbe94b386c93c19e2c1928151faa0.zip |
RESPONDERS: Fix terminating idle connections
The client_idle_handler() function tried to schedule another tevent
timer to check for idle client connections in case the current
connection was still valid, but in doing so, it also stored the current
time into the last_request_time field of the client context.
This kept the connection always alive, because the last_request_time
could then never be older than the timeout.
This patch changes the setup_client_idle_timer() function to only do
what the synopsis says and set the idle timer. The caller (usually the
function that accepts the connection) is supposed to store the request
time itself.
Resolves:
https://pagure.io/SSSD/sssd/issue/3448
Reviewed-by: Lukáš Slebodník <[email protected]>
Reviewed-by: Fabiano Fidêncio <[email protected]>
-rw-r--r-- | src/responder/common/responder_common.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/responder/common/responder_common.c b/src/responder/common/responder_common.c index f81448e1f..74c424c7b 100644 --- a/src/responder/common/responder_common.c +++ b/src/responder/common/responder_common.c @@ -608,7 +608,15 @@ static void accept_fd_handler(struct tevent_context *ev, cctx->ev = ev; cctx->rctx = rctx; - /* Set up the idle timer */ + /* Record the new time and set up the idle timer */ + ret = reset_client_idle_timer(cctx); + if (ret != EOK) { + DEBUG(SSSDBG_MINOR_FAILURE, + "Could not create idle timer for client. " + "This connection may not auto-terminate\n"); + /* Non-fatal, continue */ + } + ret = setup_client_idle_timer(cctx); if (ret != EOK) { DEBUG(SSSDBG_CRIT_FAILURE, @@ -635,7 +643,7 @@ static void client_idle_handler(struct tevent_context *ev, if (cctx->last_request_time > now) { DEBUG(SSSDBG_IMPORTANT_INFO, "Time shift detected, re-scheduling the client timeout\n"); - goto end; + goto done; } if ((now - cctx->last_request_time) > cctx->rctx->client_idle_timeout) { @@ -649,7 +657,7 @@ static void client_idle_handler(struct tevent_context *ev, return; } -end: +done: setup_client_idle_timer(cctx); } @@ -662,11 +670,9 @@ errno_t reset_client_idle_timer(struct cli_ctx *cctx) static errno_t setup_client_idle_timer(struct cli_ctx *cctx) { - time_t now = time(NULL); struct timeval tv = tevent_timeval_current_ofs(cctx->rctx->client_idle_timeout/2, 0); - cctx->last_request_time = now; talloc_zfree(cctx->idle); cctx->idle = tevent_add_timer(cctx->ev, cctx, tv, client_idle_handler, cctx); |