[FIXED] Found a deadlock
#2
This one will be tricky to fix Smile I pretty much know what the issue is, so no dump is necessary.
I think I've found the trick. In the client's RemoveFromAllChunks() I attempt remove the client from all chunks in the world, instead of having to lock the list of loaded chunks and using that.
The plus side is, removing the client doesn't need the m_CSChunkList locked anymore.
The minus side is that this solution makes a performance hit by traversing all chunks in memory, instead of only the client's ones.

I think the plus side outweighs the minus side for this solution.

Another solution I was considering was locking the list, making a copy, then removing clients from the chunks in the copy list; and cycling this until the chunklist was empty (in the case that someone somehow added the client to another chunk while the copy list was being traversed). That would incur too many locking and unlocking and I think that my final solution outperforms this one.
Note about the mentioned outperforming - code that removes a client from a list of chunks still needs to find a chunklayer for each chunk, which means traversing the list of chunklayers for each chunk in the list. That could mean an O(n * m) efficiency (n = number of chunks, m = number of chunklayers) which is actually O(n^2) because n and m are correlated. My fix is an O(n) solution (and actually an Theta(n) Wink
Reply
Thanks given by:


Messages In This Thread
[FIXED] Found a deadlock - by FakeTruth - 03-23-2012, 01:11 AM
RE: Found a deadlock - by xoft - 03-23-2012, 01:29 AM



Users browsing this thread: 1 Guest(s)