From 78cc5b72b18a3c0d196126bfbc5d3b6473386da9 Mon Sep 17 00:00:00 2001 From: rofl0r Date: Tue, 8 Sep 2020 14:36:22 +0100 Subject: get_request_entity: fix regression w/ CONNECT method introduced in 88153e944f7d28f57cccc77f3228a3f54f78ce4e. when connect method is used (HTTPS), and e.g. a filtered domain requested, there's no data on readfds, only on writefds. this caused the response from the connection to hang until the timeout was hit. in the past in such scenario always a "no entity" response was produced in tinyproxy logs. --- src/reqs.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/reqs.c b/src/reqs.c index 87a1a82..370b375 100644 --- a/src/reqs.c +++ b/src/reqs.c @@ -1485,14 +1485,15 @@ static int get_request_entity(struct conn_s *connptr) { int ret; - fd_set rset; + fd_set rset, wset; struct timeval tv; FD_ZERO (&rset); FD_SET (connptr->client_fd, &rset); + memcpy(&wset, &rset, sizeof wset); tv.tv_sec = config->idletimeout; tv.tv_usec = 0; - ret = select (connptr->client_fd + 1, &rset, NULL, NULL, &tv); + ret = select (connptr->client_fd + 1, &rset, &wset, NULL, &tv); if (ret == -1) { log_message (LOG_ERR, @@ -1514,6 +1515,8 @@ get_request_entity(struct conn_s *connptr) nread); ret = 0; } + } else if (ret == 1 && FD_ISSET (connptr->client_fd, &wset) && connptr->connect_method) { + ret = 0; } else { log_message (LOG_ERR, "strange situation after select: " "ret = %d, but client_fd (%d) is not readable...", -- cgit v1.2.3