diff options
author | Martijn van Duren <martijn@cvs.openbsd.org> | 2022-08-29 13:23:33 +0000 |
---|---|---|
committer | Martijn van Duren <martijn@cvs.openbsd.org> | 2022-08-29 13:23:33 +0000 |
commit | 0b990007fff152e5c3df47ed57ce8f2882a87d38 (patch) | |
tree | f6e9d2b03a309997b29650350152e43c2030855c /usr.sbin/snmpd | |
parent | 5e9eabef0b65862becc8fe92a63e948394d528b2 (diff) |
When a backend disappears while handling a request, make sure that the
outstanding requests are handled by the next backend, instead of leaking
memory.
OK tb@
Diffstat (limited to 'usr.sbin/snmpd')
-rw-r--r-- | usr.sbin/snmpd/application.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/usr.sbin/snmpd/application.c b/usr.sbin/snmpd/application.c index 9d967600868..649c3de801b 100644 --- a/usr.sbin/snmpd/application.c +++ b/usr.sbin/snmpd/application.c @@ -1,4 +1,4 @@ -/* $OpenBSD: application.c,v 1.8 2022/08/29 13:19:05 martijn Exp $ */ +/* $OpenBSD: application.c,v 1.9 2022/08/29 13:23:32 martijn Exp $ */ /* * Copyright (c) 2021 Martijn van Duren <martijn@openbsd.org> @@ -724,6 +724,7 @@ void appl_request_downstream_free(struct appl_request_downstream *dreq) { struct appl_varbind_internal *vb; + int retry = 0; if (dreq == NULL) return; @@ -731,9 +732,16 @@ appl_request_downstream_free(struct appl_request_downstream *dreq) RB_REMOVE(appl_requests, &(dreq->ard_backend->ab_requests), dreq); evtimer_del(&(dreq->ard_timer)); - for (vb = dreq->ard_vblist; vb != NULL; vb = vb->avi_next) + for (vb = dreq->ard_vblist; vb != NULL; vb = vb->avi_next) { vb->avi_request_downstream = NULL; + if (vb->avi_state == APPL_VBSTATE_PENDING) { + vb->avi_state = APPL_VBSTATE_NEW; + retry = 1; + } + } + if (retry) + appl_request_upstream_resolve(dreq->ard_request); free(dreq); } |