Skip to content
This repository was archived by the owner on Apr 23, 2023. It is now read-only.

Commit fab509c

Browse files
committed
"Fixed" segfault
1 parent 84f253b commit fab509c

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

src/FileServer.cpp

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -310,21 +310,28 @@ void FileServer::cleanupClients()
310310
time_t now = time(NULL);
311311

312312
std::unique_lock<std::mutex> mlock(*clientsMutex);
313-
auto i = clients->begin();
314-
while (i != clients->end())
313+
try
315314
{
316-
FileClientConnection *c = i->second;
317-
if (c && difftime(now, c->lastMessageTime) > 10)
315+
auto i = clients->begin();
316+
while (i != clients->end())
318317
{
319-
cout << "Removing client: " << c->clientId << " for inactivity." << endl;
320-
disconnectClient(c);
321-
i = clients->erase(i);
322-
}
323-
else
324-
{
325-
i++;
318+
FileClientConnection *c = i->second;
319+
if (c && difftime(now, c->lastMessageTime) > 10)
320+
{
321+
cout << "Removing client: " << c->clientId << " for inactivity." << endl;
322+
323+
disconnectClient(c);
324+
i = clients->erase(i);
325+
}
326+
else
327+
{
328+
i++;
329+
}
326330
}
327331
}
332+
catch (...)
333+
{
334+
}
328335
mlock.unlock();
329336
}
330337

0 commit comments

Comments
 (0)