Fix a bug where select() could fail due to negative max socket fd.
Connection objects in the disconnected state should not have their fd taken into account when determining the maximum socket fd number, as they are not set in the bitmask with FD_SET, and their fd could be anything, even a wildly large or small number.
This commit is contained in:
@@ -218,7 +218,8 @@ void xmpp_run_once(xmpp_ctx_t *ctx, const unsigned long timeout)
|
||||
tls_read_bytes += tls_pending(conn->tls);
|
||||
}
|
||||
|
||||
if (conn->sock > max) max = conn->sock;
|
||||
if (conn->state != XMPP_STATE_DISCONNECTED && conn->sock > max)
|
||||
max = conn->sock;
|
||||
|
||||
connitem = connitem->next;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user