Browse Source

deadlock fixes

Fix #94 and also parital fix #91
Image 4 years ago
parent
commit
b7adfe1ba0
1 changed files with 9 additions and 1 deletions
  1. 9 1
      EQ2/source/WorldServer/zoneserver.cpp

+ 9 - 1
EQ2/source/WorldServer/zoneserver.cpp

@@ -1469,7 +1469,10 @@ bool ZoneServer::SpawnProcess(){
 		for (itr = spawn_list.begin(); itr != spawn_list.end(); itr++) {
 			// if zone is shutting down kill the loop
 			if (zoneShuttingDown)
+			{
+				MSpawnList.releasereadlock(__FUNCTION__, __LINE__);
 				break;
+			}
 
 			Spawn* spawn = itr->second;
 			if (spawn) {
@@ -1502,7 +1505,10 @@ bool ZoneServer::SpawnProcess(){
 		for (itr = spawn_list.begin(); itr != spawn_list.end(); itr++) {
 			// Break the loop if the zone is shutting down
 			if (zoneShuttingDown)
+			{
+				MSpawnList.releasereadlock(__FUNCTION__, __LINE__);
 				break;
+			}
 
 			Spawn* spawn = itr->second;
 			if (spawn) {
@@ -1606,7 +1612,9 @@ void ZoneServer::CheckDeadSpawnRemoval() {
 				if (!spawn->IsPlayer())
 				{
 					dead_spawns.erase(spawn->GetID());
-					RemoveSpawn(true, spawn, true, true, false);
+					MDeadSpawns.releasewritelock(__FUNCTION__, __LINE__);
+					RemoveSpawn(false, spawn, true, true, true);
+					MDeadSpawns.writelock(__FUNCTION__, __LINE__);
 				}
 			}
 		}