Browse Source

Fixed bugreport:5989 map-server crashes.

Bug in Detail:
 - Uninitialized Critical Section used in Condition Variables.. 
 - Possible Stack Overflow in async allocator Thread when build as Release 

Fixed by: 
 - Initialize Critical Section for Condition Var's waiter count lock properly
 - Increased Stack Size of Async. Allocator Thread to 1MB (previously 512KB)


git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@16269 54d463be-8e91-2dee-dedb-b68131a5f0ec
blacksirius 13 years ago
parent
commit
04bc22ca40
2 changed files with 3 additions and 2 deletions
  1. 1 1
      src/common/mempool.c
  2. 2 1
      src/common/mutex.c

+ 1 - 1
src/common/mempool.c

@@ -156,7 +156,7 @@ void mempool_init(){
 	l_async_lock = ramutex_create();
 	l_async_cond = racond_create();
 
-	l_async_thread = rathread_createEx(mempool_async_allocator, NULL,  512*1024,  RAT_PRIO_NORMAL);
+	l_async_thread = rathread_createEx(mempool_async_allocator, NULL, 1024*1024,  RAT_PRIO_NORMAL);
 	if(l_async_thread == NULL){
 		ShowFatalError("mempool_init: cannot spawn Async Allocator Thread.\n");
 		exit(EXIT_FAILURE);

+ 2 - 1
src/common/mutex.c

@@ -133,6 +133,7 @@ racond racond_create(){
 	c->nWaiters = 0;
 	c->events[ EVENT_COND_SIGNAL ]		= CreateEvent( NULL,  FALSE,  FALSE,  NULL );
 	c->events[ EVENT_COND_BROADCAST ]	= CreateEvent( NULL,  TRUE,   FALSE,  NULL );
+	InitializeCriticalSection( &c->waiters_lock );
 #else
 	pthread_cond_init(&c->hCond, NULL);
 #endif
@@ -145,7 +146,7 @@ void racond_destroy( racond c ){
 #ifdef WIN32
 	CloseHandle( c->events[ EVENT_COND_SIGNAL ] );
 	CloseHandle( c->events[ EVENT_COND_BROADCAST ] );
-	InitializeCriticalSection( &c->waiters_lock );
+	DeleteCriticalSection( &c->waiters_lock );
 #else
 	pthread_cond_destroy(&c->hCond);
 #endif