From b4ffc5686f8cc2603e76a6c1c912d6138982442b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?= <grubba@grubba.org> Date: Wed, 2 May 2018 16:08:08 +0200 Subject: [PATCH] Protocols.HTTP.Query: Do not wait for close() to complete. Do not wait for SSL.File()->close() to complete when called from the destruct() callback. Potential fix for [PIKE-84]. --- .../Protocols.pmod/HTTP.pmod/Query.pike | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/lib/modules/Protocols.pmod/HTTP.pmod/Query.pike b/lib/modules/Protocols.pmod/HTTP.pmod/Query.pike index 7e9e3ab0e6..176a45da32 100644 --- a/lib/modules/Protocols.pmod/HTTP.pmod/Query.pike +++ b/lib/modules/Protocols.pmod/HTTP.pmod/Query.pike @@ -168,12 +168,28 @@ protected int ponder_answer( int|void start_position ) return 1; } -protected void close_connection() +protected void close_connection(int|void terminate_now) { - Stdio.File con = this::con; + object(Stdio.File)|SSL.File con = this::con; if (!con) return; this::con = 0; con->set_callbacks(0, 0, 0, 0, 0); // Clear any remaining callbacks. + + if (terminate_now) { + // We don't want to wait for the close() to complete... + con->set_nonblocking(); + con->close(); + + if (!con->shutdown) return; + + // Probably SSL. + // + // Force the connection to shutdown. + con = con->shutdown(); + + if (!con) return; + } + con->close(); } @@ -1199,8 +1215,12 @@ protected void destroy() remove_call_out(async_id); } async_id = 0; + if(async_dns) { + async_dns->close(); + async_dns = 0; + } - catch(close()); + catch(close_connection(1)); } //! Close all associated file descriptors. -- GitLab