This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients giampaolo.rodola, glyph, gvanrossum, neologix, pitrou, sbt, vstinner, yselivanov
Date 2015-02-04.16:41:17
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1423068078.32.0.05231078548.issue19017@psf.upfronthosting.co.za>
In-reply-to
Content
> 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.
History
Date User Action Args
2015-02-04 16:41:18vstinnersetrecipients: + vstinner, gvanrossum, pitrou, giampaolo.rodola, glyph, neologix, sbt, yselivanov
2015-02-04 16:41:18vstinnersetmessageid: <1423068078.32.0.05231078548.issue19017@psf.upfronthosting.co.za>
2015-02-04 16:41:18vstinnerlinkissue19017 messages
2015-02-04 16:41:17vstinnercreate