mirror of
https://github.com/espressif/esp-idf
synced 2025-03-09 17:19:09 -04:00
fix(tcp_tranport): Fix handling of select() return value
When both readset/writeset and errset are set for a single socket, the HTTP client incorrectly handled the condition, causing premature termination. Added a check to ensure readset/writeset is prioritized before errset. Closes https://github.com/espressif/esp-idf/issues/14673
This commit is contained in:
parent
945d750d5a
commit
5ad73e97e8
@ -174,7 +174,10 @@ static int base_poll_read(esp_transport_handle_t t, int timeout_ms)
|
||||
return remain;
|
||||
}
|
||||
ret = select(ssl->sockfd + 1, &readset, NULL, &errset, esp_transport_utils_ms_to_timeval(timeout_ms, &timeout));
|
||||
if (ret > 0 && FD_ISSET(ssl->sockfd, &errset)) {
|
||||
// The select() function monitors the socket for readiness to read or write, and checks for errors.
|
||||
// If both an error (errset) and readiness (readset/writeset) are detected simultaneously,
|
||||
// this code ensures that the pending read data must be handled before we start processing error.
|
||||
if (ret == 1 && FD_ISSET(ssl->sockfd, &errset)) {
|
||||
int sock_errno = 0;
|
||||
uint32_t optlen = sizeof(sock_errno);
|
||||
getsockopt(ssl->sockfd, SOL_SOCKET, SO_ERROR, &sock_errno, &optlen);
|
||||
|
Loading…
x
Reference in New Issue
Block a user