From a2722019a379f83ee5a1b35a1a100400e3e7170e Mon Sep 17 00:00:00 2001 From: Haru Date: Wed, 18 Sep 2013 16:30:52 +0200 Subject: Fixed a race condition leading to a crash on server shutdown on linux Fixes bugreport:7699, thanks to bgamez23 (bugreport), Ind (testing, brainstorming) http://hercules.ws/board/tracker/issue-7699-map-crashed-on-the-latest-version/ Signed-off-by: Haru --- src/common/thread.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/common/thread.c b/src/common/thread.c index 315b310b2..4d110f2dd 100644 --- a/src/common/thread.c +++ b/src/common/thread.c @@ -96,15 +96,11 @@ void rathread_final(){ // gets called whenever a thread terminated .. -static void rat_thread_terminated( rAthread handle ){ - - int id_backup = handle->myID; - - // Simply set all members to 0 (except the id) - memset(handle, 0x00, sizeof(struct rAthread)); - - handle->myID = id_backup; // done ;) - +static void rat_thread_terminated(rAthread handle) { + // Preserve handle->myID and handle->hThread, set everything else to its default value + handle->param = NULL; + handle->proc = NULL; + handle->prio = RAT_PRIO_NORMAL; }//end: rat_thread_terminated() #ifdef WIN32 -- cgit v1.2.3-60-g2f50