Fixed network manager destructor not to have memory access problems.

This commit is contained in:
Pauli Nieminen 2008-09-17 10:15:10 +00:00
parent 4168e62d4f
commit 67ff80767a

View file

@ -135,7 +135,8 @@ struct buffer {
};
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 @@ manager::~manager()
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();
delete shard_mutexes[shard];
shard_mutexes[shard] = NULL;
to_clear[shard].clear();
delete cond[shard];
cond[shard] = NULL;
delete shard_mutexes[shard];
shard_mutexes[shard] = NULL;
}
delete stats_mutex;