summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorrofl0r <rofl0r@users.noreply.github.com>2020-09-08 14:36:22 +0100
committerrofl0r <rofl0r@users.noreply.github.com>2020-09-08 14:45:24 +0100
commit78cc5b72b18a3c0d196126bfbc5d3b6473386da9 (patch)
tree741aab9f83edff004908dfe03d23702ac35185a4
parent58cfaf2659a4daca9bc8933f1ce135ba619557da (diff)
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.
-rw-r--r--src/reqs.c7
1 files 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...",