Message235388
> 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. |
|
Date |
User |
Action |
Args |
2015-02-04 16:41:18 | vstinner | set | recipients:
+ vstinner, gvanrossum, pitrou, giampaolo.rodola, glyph, neologix, sbt, yselivanov |
2015-02-04 16:41:18 | vstinner | set | messageid: <1423068078.32.0.05231078548.issue19017@psf.upfronthosting.co.za> |
2015-02-04 16:41:18 | vstinner | link | issue19017 messages |
2015-02-04 16:41:17 | vstinner | create | |
|