Skip to content

Commit

Permalink
Update SocketServer.h (#1619)
Browse files Browse the repository at this point in the history
  • Loading branch information
pwielders authored May 30, 2024
1 parent d31ef9a commit 1e0e46f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Source/core/SocketServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,18 @@ namespace Core {
typename ClientMap::iterator index = _clients.begin();

while (index != _clients.end()) {
if ((index->second->IsClosed() == true) || ((index->second->IsSuspended() == true) && (index->second->Close(100) == Core::ERROR_NONE))) {
// Do not change the Close() duration to a value >0. We should just test, but not wait for a statechange.
// Waiting for a Statwchange might require, in the SocketPort imlementation of Close, WaitForCloseure with
// parameter Core::infinite in case we have a faulthy socket. This call will than only return if the
// ResourceMonitor thread does report on CLosure of the socket. However, the ResourceMonitor thread might
// also be calling into here for an Accept.
// In that case, the Accept will block on the _lock from this object as it is taken by this Cleanup call
// running on a different thread but also this lock will not be freed as this cleanup thread is waiting
// now on the WaitForClosure that needs attention from the ResourceMonitor thread, which is currently
// blocked by the Accpet, waiting for this lock ;-)
// By setting the Close wait time to 0, it wil never require the ReourceMonitor thread to participate
// in the evaluatio of this socket state and thus in due time, the Server lock is *always* released.
if ((index->second->IsClosed() == true) || ((index->second->IsSuspended() == true) && (index->second->Close(0) == Core::ERROR_NONE))) {
// Step forward but remember where we were and delete that one....
index = _clients.erase(index);
}
Expand Down

0 comments on commit 1e0e46f

Please sign in to comment.