]> git.ipfire.org Git - people/ms/strongswan.git/commitdiff
host-resolver: Don't wait for a reply if there are no threads
authorTobias Brunner <tobias@strongswan.org>
Fri, 20 Nov 2020 14:02:30 +0000 (15:02 +0100)
committerTobias Brunner <tobias@strongswan.org>
Thu, 3 Dec 2020 07:36:20 +0000 (08:36 +0100)
Without threads handling the resolution, there is no point waiting
for a reply.  If no subsequent resolution successfully starts a
thread (there might not even be one), we'd wait indefinitely.

Fixes #3634.

src/libstrongswan/networking/host_resolver.c

index 580931e1fa7310a26e477f867d3247d73ed522ed..8326a1d9cd5498b00e829bf0ba3ea78cef09f5ea 100644 (file)
@@ -287,7 +287,20 @@ METHOD(host_resolver_t, resolve, host_t*,
                        this->pool->insert_last(this->pool, thread);
                }
        }
-       query->done->wait(query->done, this->mutex);
+       if (this->threads)
+       {
+               query->done->wait(query->done, this->mutex);
+       }
+       else
+       {
+               DBG1(DBG_LIB, "resolving '%s' failed: no resolver threads", query->name);
+               /* this should always be the case if we end up here, but make sure */
+               if (query->refcount == 1)
+               {
+                       this->queries->remove(this->queries, query);
+                       this->queue->remove_last(this->queue, (void**)&query);
+               }
+       }
        this->mutex->unlock(this->mutex);
 
        result = query->result ? query->result->clone(query->result) : NULL;