diff options
author | Simo Sorce <simo@redhat.com> | 2012-12-14 14:59:21 -0500 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2012-12-18 18:42:11 +0100 |
commit | 185dcb88690f45c7886c95076bd189877aef2289 (patch) | |
tree | d2abe6d0c7d69930288b508fd8c8f5dc093d710f /src/responder/common | |
parent | ccb2c1f30b04bf1f7a33f47748664dedb7ddd0e3 (diff) | |
download | sssd-185dcb88690f45c7886c95076bd189877aef2289.tar.gz sssd-185dcb88690f45c7886c95076bd189877aef2289.tar.bz2 sssd-185dcb88690f45c7886c95076bd189877aef2289.zip |
responder_dp: Add timeout to side requets
This is an additional proteciont in case the provider misbheaves to avoid
having requests pending forever.
Fixes: https://fedorahosted.org/sssd/ticket/1717
Diffstat (limited to 'src/responder/common')
-rw-r--r-- | src/responder/common/responder_dp.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/responder/common/responder_dp.c b/src/responder/common/responder_dp.c index ecd5f39c..d15ca4dc 100644 --- a/src/responder/common/responder_dp.c +++ b/src/responder/common/responder_dp.c @@ -45,7 +45,6 @@ struct sss_dp_req { hash_key_t *key; - struct tevent_timer *tev; struct sss_dp_callback *cb_list; dbus_uint16_t dp_err; @@ -126,6 +125,15 @@ static int sss_dp_req_destructor(void *ptr) return 0; } +static void sss_dp_req_timeout(struct tevent_context *ev, + struct tevent_timer *te, + struct timeval t, void *ptr) +{ + /* ptr is a pointer to sidereq */ + /* Just free it to kill all waiting requests when the timeout fires */ + talloc_zfree(ptr); +} + void handle_requests_after_reconnect(struct resp_ctx *rctx) { int ret; @@ -252,6 +260,8 @@ sss_dp_issue_request(TALLOC_CTX *mem_ctx, struct resp_ctx *rctx, struct tevent_req *sidereq; struct sss_dp_req *sdp_req; struct sss_dp_callback *cb; + struct tevent_timer *te; + struct timeval tv; DBusMessage *msg; TALLOC_CTX *tmp_ctx = NULL; errno_t ret; @@ -306,6 +316,20 @@ sss_dp_issue_request(TALLOC_CTX *mem_ctx, struct resp_ctx *rctx, } tevent_req_set_callback(sidereq, sss_dp_req_done, NULL); + /* add timeout handling so we do not hang forever should something + * go worng in the provider. Use 2 sec less than the idle timeout to + * give it a chance to reply to the client before closing the + * connection. */ + tv = tevent_timeval_current_ofs(rctx->client_idle_timeout - 2, 0); + te = tevent_add_timer(rctx->ev, sidereq, tv, + sss_dp_req_timeout, sidereq); + if (!te) { + /* Nothing much we can do */ + DEBUG(SSSDBG_CRIT_FAILURE, ("Out of memory?!\n")); + ret = ENOMEM; + goto fail; + } + /* We should now be able to find the sdp_req in the hash table */ hret = hash_lookup(rctx->dp_request_table, key, &value); if (hret != HASH_SUCCESS) { |