Cuberite Forum
[FIXED] I found a deadlock - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Cuberite (https://forum.cuberite.org/forum-4.html)
+--- Forum: Development (https://forum.cuberite.org/forum-13.html)
+--- Thread: [FIXED] I found a deadlock (/thread-374.html)



[FIXED] I found a deadlock - FakeTruth - 03-04-2012

A quick overview of what thread locks what criticalsection
Code:
ServerTickThread
Owns cServer::m_CSClients
Wait cSocketThreads::m_CS

cSocketThread
Owns cSocketThreads::m_CS
Wait cServer::m_CSClients

cServer::ServerListenThread
Wait cSocketThreads::m_CS // Doesn't really matter, but it blocks new clients

The deadlock is between ServerTickThread and cSocketThread

ServerTickThread callstack:
[Image: Screenshot-2012-03-04_14.13.04.png]


cSocketThread callstack:
[Image: Screenshot-2012-03-04_14.14.23.png]


RE: I found a deadlock - xoft - 03-05-2012

I guess client deleting can be done postponed - in the TickThread make a list of clients to be deleted, move clients to that list while the CS is locked, then unlock the CS and delete clients from the list.


RE: I found a deadlock - xoft - 03-06-2012

I fixed your deadlock (rev 369)