From 76dfdd5ae7e0f7ce619c51f9df4e5b8f59c50955 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?=
 <grubba@grubba.org>
Date: Wed, 22 Feb 2017 15:04:52 +0100
Subject: [PATCH] Protocols.HTTP.do_async_proxied_method: Fix timeout handling.

The HTTP timeout was lost during TLS negotiation.

Fixes [PIKE-7].
---
 lib/modules/Protocols.pmod/HTTP.pmod/module.pmod | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lib/modules/Protocols.pmod/HTTP.pmod/module.pmod b/lib/modules/Protocols.pmod/HTTP.pmod/module.pmod
index cf50fd6555..8348563f62 100644
--- a/lib/modules/Protocols.pmod/HTTP.pmod/module.pmod
+++ b/lib/modules/Protocols.pmod/HTTP.pmod/module.pmod
@@ -467,8 +467,14 @@ protected void https_proxy_connect_ok(Protocols.HTTP.Query con,
 {
   con->set_callbacks(@orig_cb_info);
 
+  // Install the timeout handler for the interval until
+  // the TLS connection is up.
+  con->init_async_timeout();
   con->con->set_nonblocking(0,
 			    lambda() {
+			      // Remove the timeout handler; it will be
+			      // reinstated by do_async_method() below.
+			      con->remove_async_timeout();
 			      do_async_method(method, url, query_variables,
 					      request_headers, con, data);
 			    }, con->async_failed);
-- 
GitLab