Skip to content

Commit dd138db

Browse files
committed
[nrf fromlist] net: http_client: Fix handling of POLLHUP
POLLHUP event may be returned even if there is still data to read and POLLIN is set. To ensure all data is consumed, check for POLLHUP after handling POLLIN. https://man7.org/linux/man-pages/man2/poll.2.html Upstream PR #: 92241 Signed-off-by: Juha Ylinen <[email protected]> (cherry picked from commit a474c9722f0c400a362e6f962943148808b040de)
1 parent 93aefcf commit dd138db

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

subsys/net/lib/http/http_client.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -517,9 +517,6 @@ static int http_wait_data(int sock, struct http_request *req, const k_timepoint_
517517
} else if (fds[0].revents & ZSOCK_POLLNVAL) {
518518
ret = -EBADF;
519519
goto error;
520-
} else if (fds[0].revents & ZSOCK_POLLHUP) {
521-
/* Connection closed */
522-
goto closed;
523520
} else if (fds[0].revents & ZSOCK_POLLIN) {
524521
received = zsock_recv(sock, req->internal.response.recv_buf + offset,
525522
req->internal.response.recv_buf_len - offset, 0);
@@ -593,6 +590,9 @@ static int http_wait_data(int sock, struct http_request *req, const k_timepoint_
593590
req->internal.response.recv_buf + processed,
594591
offset);
595592
}
593+
} else if (fds[0].revents & ZSOCK_POLLHUP) {
594+
/* Connection closed */
595+
goto closed;
596596
}
597597

598598
} while (!req->internal.response.message_complete);

0 commit comments

Comments
 (0)