get_request_entity: fix regression w/ CONNECT method

introduced in 88153e944f.
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.
This commit is contained in:
rofl0r 2020-09-08 14:36:22 +01:00
parent 58cfaf2659
commit 78cc5b72b1

View File

@ -1485,14 +1485,15 @@ static int
get_request_entity(struct conn_s *connptr) get_request_entity(struct conn_s *connptr)
{ {
int ret; int ret;
fd_set rset; fd_set rset, wset;
struct timeval tv; struct timeval tv;
FD_ZERO (&rset); FD_ZERO (&rset);
FD_SET (connptr->client_fd, &rset); FD_SET (connptr->client_fd, &rset);
memcpy(&wset, &rset, sizeof wset);
tv.tv_sec = config->idletimeout; tv.tv_sec = config->idletimeout;
tv.tv_usec = 0; 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) { if (ret == -1) {
log_message (LOG_ERR, log_message (LOG_ERR,
@ -1514,6 +1515,8 @@ get_request_entity(struct conn_s *connptr)
nread); nread);
ret = 0; ret = 0;
} }
} else if (ret == 1 && FD_ISSET (connptr->client_fd, &wset) && connptr->connect_method) {
ret = 0;
} else { } else {
log_message (LOG_ERR, "strange situation after select: " log_message (LOG_ERR, "strange situation after select: "
"ret = %d, but client_fd (%d) is not readable...", "ret = %d, but client_fd (%d) is not readable...",