It is possible that select() marks a descriptor as ready for both read
and write operation. If, additionally, the socket becomes closed in
ReadyForRead(), the following call to ReadyForWrite() will attempt to
write to a closed socket. It is harmless, unless the closed descriptor
is already reused by another thread at the time of write().
This commit prevents it.
Change-Id: Idaa829ef74d6df9f24c263f289aeca910b679713
}
if (FD_ISSET(i, &writeSet)) {
- ReadyForWrite(i);
+ // it is possible that the socket was closed in preceding call to ReadyForRead()
+ if (m_socketDescriptionVector[i].isOpen())
+ ReadyForWrite(i);
--ret;
}
}