STINNER Victor added the comment: > To find an invalid FD when select() fails with EBAD, we can use something > like: > http://ufwi.org/projects/nufw/repository/revisions/b4f66edc5d4dc837f75857f8bffe9015454fdebc/entry/src/nuauth/tls_nufw.c#L408
Oh, the link is dead. Copy/paste of the code: --- /* errno == EBADF */ int i; /* A client disconnects between FD_SET and select. * Will try to find it */ for (i=0; i<context->mx; ++i){ struct stat s; if (FD_ISSET(i, &context->tls_rx_set)){ if (fstat(i, &s)<0) { log_message(CRITICAL, DEBUG_AREA_USER, "Warning: %d is a bad file descriptor.", i); FD_CLR(i, &context->tls_rx_set); } } } continue; /* retry select */ --- In short: call fstat() if check if the FD is valid or not. O(n) complexity. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue19017> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com