aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/librdns/util.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2022-02-05 12:28:30 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2022-02-05 12:28:30 +0000
commit4899f78701054febc0a9fab2af754f2040373401 (patch)
tree53d6061f03cae106f84f27d9876ef366fbb5037a /contrib/librdns/util.c
parent2fe30027a9f30877bb108e887ac74cbbb4a3fe95 (diff)
downloadrspamd-4899f78701054febc0a9fab2af754f2040373401.tar.gz
rspamd-4899f78701054febc0a9fab2af754f2040373401.zip
[Fix] Rework unshedule DNS request function
Diffstat (limited to 'contrib/librdns/util.c')
-rw-r--r--contrib/librdns/util.c39
1 files changed, 28 insertions, 11 deletions
diff --git a/contrib/librdns/util.c b/contrib/librdns/util.c
index 900791b14..e09eb2007 100644
--- a/contrib/librdns/util.c
+++ b/contrib/librdns/util.c
@@ -635,8 +635,12 @@ rdns_request_retain (struct rdns_request *req)
void
rdns_request_unschedule (struct rdns_request *req, bool remove_from_hash)
{
- if (req->async_event) {
- if (req->state == RDNS_REQUEST_WAIT_REPLY) {
+ struct rdns_resolver *resolver = req->resolver;
+
+ switch (req->state) {
+ case RDNS_REQUEST_WAIT_REPLY:
+ /* We have a timer pending */
+ if (req->async_event) {
req->async->del_timer (req->async->data,
req->async_event);
if (remove_from_hash) {
@@ -644,7 +648,10 @@ rdns_request_unschedule (struct rdns_request *req, bool remove_from_hash)
}
req->async_event = NULL;
}
- else if (req->state == RDNS_REQUEST_WAIT_SEND) {
+ break;
+ case RDNS_REQUEST_WAIT_SEND:
+ /* We have write request pending */
+ if (req->async_event) {
req->async->del_write (req->async->data,
req->async_event);
/* Remove from id hashes */
@@ -653,16 +660,26 @@ rdns_request_unschedule (struct rdns_request *req, bool remove_from_hash)
}
req->async_event = NULL;
}
- }
- else if (req->state == RDNS_REQUEST_TCP) {
- if (remove_from_hash) {
- rdns_request_remove_from_hash(req);
- }
+ break;
+ case RDNS_REQUEST_TCP:
+ /* We also have a timer */
+ if (req->async_event) {
+ if (remove_from_hash) {
+ rdns_request_remove_from_hash(req);
+ }
- req->async->del_timer(req->async->data,
- req->async_event);
+ req->async->del_timer(req->async->data,
+ req->async_event);
- req->async_event = NULL;
+ req->async_event = NULL;
+ }
+ default:
+ /* Nothing to unschedule, so blame if we have any event pending */
+ if (req->async_event) {
+ rdns_err("internal error: have unexpected pending async state on stage %d",
+ req->state);
+ }
+ break;
}
}