return -1;
}
-void
+bool
IdleConnList::removeFD(int fd)
{
int index = findFDIndex(fd);
if (index < 0) {
debugs(48, 2, "IdleConnList::removeFD: FD " << fd << " NOT FOUND!");
- return;
+ return false;
}
debugs(48, 3, "IdleConnList::removeFD: found FD " << fd << " at index " << index);
debugs(48, 3, "IdleConnList::removeFD: deleting " << hashKeyStr(&hash));
delete this;
}
+ return true;
}
void
}
IdleConnList *list = (IdleConnList *) data;
- list->removeFD(fd); /* might delete list */
- comm_close(fd);
+ if (list->removeFD(fd)) /* might delete list */
+ comm_close(fd);
}
void
{
debugs(48, 3, "IdleConnList::timeout: FD " << fd);
IdleConnList *list = (IdleConnList *) data;
- list->removeFD(fd); /* might delete list */
- comm_close(fd);
+ if (list->removeFD(fd)) /* might delete list */
+ comm_close(fd);
}
/* ========== PconnPool PRIVATE FUNCTIONS ============================================ */
if (fd >= 0) {
list->clearHandlers(fd);
- list->removeFD(fd); /* might delete list */
- if (!isRetriable) {
+ /* might delete list */
+ if (list->removeFD(fd) && !isRetriable) {
comm_close(fd);
return -1;
}
int numIdle() { return nfds; }
int findFDIndex(int fd); ///< search from the end of array
- void removeFD(int fd);
+
+ /// If false the FD does not currently exist in the list.
+ /// We seem to have hit and lost a race condition.
+ /// Nevermind, but MUST NOT do anything with the raw FD.
+ bool removeFD(int fd);
+
void push(int fd);
int findUseableFD(); ///< find first from the end not pending read fd.
void clearHandlers(int fd);