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:
Codewalker
2014-12-24 12:04:39 -06:00
parent 0fed8a55e4
commit b753e6cf18

View File

@@ -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;
}