Author: suokko
Date: Wed Sep 17 12:01:07 2008
New Revision: 29512
URL: http://svn.gna.org/viewcvs/wesnoth?rev=29512&view=rev
Log:
Fixed network manager destructor not to have memory access problems.
Modified:
tags/1.4.5/src/network_worker.cpp
Modified: tags/1.4.5/src/network_worker.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/tags/1.4.5/src/network_worker.cpp?rev=29512&r1=29511&r2=29512&view=diff
==============================================================================
--- tags/1.4.5/src/network_worker.cpp (original)
+++ tags/1.4.5/src/network_worker.cpp Wed Sep 17 12:01:07 2008
@@ -135,7 +135,8 @@
};
-bool managed = false, raw_data_only = false;
+bool volatile managed = false;
+bool raw_data_only = false;
typedef std::vector< buffer* > buffer_set;
buffer_set outgoing_bufs[NUM_SHARDS];
@@ -748,11 +749,20 @@
DBG_NW << "thread exited...\n";
}
+ // Condition variables must be deleted first as
+ // they make reference to mutexs. If the mutexs
+ // are destroyed first, the condition variables
+ // will access memory already freed by way of
+ // stale mutex. Bad things will follow. ;)
+
threads[shard].clear();
+
+ to_clear[shard].clear();
+
+ delete cond[shard];
+ cond[shard] = NULL;
delete shard_mutexes[shard];
shard_mutexes[shard] = NULL;
- delete cond[shard];
- cond[shard] = NULL;
}
delete stats_mutex;
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits