 |
Server Help Community forums for Subgame, ASSS, and bots
|
Author |
Message |
50% Packetloss Server Help Squatter

Age:40 Gender: Joined: Sep 09 2003 Posts: 561 Location: Santa Clarita, California Offline
|
Posted: Fri Apr 01, 2005 1:20 am Post subject: deadlock.c |
 |
|
|
|
On my computer, it is impossible to shutdown ASSS properly without deadlock.c calling abort() and windows displaying a gay message about the program terminating in an odd manner. Well I narrowed the problem down to deadlock itself. When ASSS is closed (ctrl+c) the program runs a function called UnloadAllModules which in turn runs recursive_unload (it calls all of the module's entry point functions with action = MM_UNLOAD).
Here is the code from deadlock's entry point
if (action == MM_LOAD)
{
pthread_create(&thd, NULL, thread_check, NULL);
mm->RegCallback(CB_MAINLOOP, increment, ALLARENAS);
return MM_OK;
}
else if (action == MM_UNLOAD)
{
mm->UnregCallback(CB_MAINLOOP, increment, ALLARENAS);
pthread_cancel(thd);
pthread_join(thd, NULL);
return MM_OK;
} |
Deadlock is a module that makes sure that ASSS doesn't freeze up, and if it does it will terminate the program. It does this through a seperate thread of its own (the 2nd function is just so you can follow the code):
local void * thread_check(void *dummy)
{
/* wait a minute initially */
fullsleep(60 * 1000);
for (;;)
{
int seen = counter;
/* and then 10 seconds each iteration */
fullsleep(10 * 1000);
if (counter == seen)
{
fprintf(stderr, "E <deadlock> deadlock detected, aborting\n");
abort();
}
}
}
local void increment(void)
{
counter++;
}
|
Now, the problem IS "pthread_join(thd, NULL);" (found in the mm_unload section). I don't know a lot about threads and absolutly nothing about pthreads but I believe this function's purpose is to wait for the thread to terminate. Inorder for the thread to terminate the function has to return, but this isn't possible with an infinate for(;;) loop. So not only does it take an ass-load of time for the sleep() timers to end, but then the thread wont terminate and calls abort(). I did a crappy fix and ASSS closed perfectly (minus waiting for the sleep() timers to get done).
I could be completely wrong about all of this but it all seems logical. I tried talking to grel on his server, but he was afk and my laptop's wifi gets a lot of ploss and I get kicked out.
I think that the above is only a windows problem, because I haven't heard of any linux people complaining. I use Windows XP home edition on a Presario 905us laptop. I use the VC build of the most current version of ASSS (but I noticed the above problem with the build found on ASSS's homepage, so it's not associated with my build, which works perfecly I might add). _________________ Current Terror Alert Level
 |
|
Back to top |
|
 |
Bak ?ls -s 0 in

Age:26 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
|
Back to top |
|
 |
50% Packetloss Server Help Squatter

Age:40 Gender: Joined: Sep 09 2003 Posts: 561 Location: Santa Clarita, California Offline
|
|
Back to top |
|
 |
Grelminar Creator of Asss
Joined: Feb 26 2003 Posts: 378 Offline
|
Posted: Fri Apr 01, 2005 3:38 am Post subject: |
 |
|
|
|
The problem seems to be that while nanosleep (which is used to implement fullsleep on unix) is a pthread cancellation point, usleep on windows is not a cancellation point (which isn't surprising, since it's part of the windows C library, which knows nothing about the pthreads).
There are a few possible fixes: You could add "pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);" to the beginning of the deadlock thread. Or you could change the windows implementation of fullsleep (in util.c) to use the function pthreadCancelableTimedWait from the pthread-win32 library, which would make the sleep a cancellation point. I would try the first one first. |
|
Back to top |
|
 |
50% Packetloss Server Help Squatter

Age:40 Gender: Joined: Sep 09 2003 Posts: 561 Location: Santa Clarita, California Offline
|
Posted: Fri Apr 01, 2005 4:03 am Post subject: |
 |
|
|
|
Thanks grel. I'll give it a try.
On a side note, maybe add a ToLowerStr(params) to void Cprize in playercmd.c because strstr isn't case-insensitive. But it doesn't matter. |
|
Back to top |
|
 |
50% Packetloss Server Help Squatter

Age:40 Gender: Joined: Sep 09 2003 Posts: 561 Location: Santa Clarita, California Offline
|
Posted: Fri Apr 01, 2005 4:20 am Post subject: |
 |
|
|
|
Yah, the "pthread_setcanceltype" seems to work, still takes a bit of time to terminate (probably from all the stuff net.c has to do) but much better. |
|
Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
Software by php BB © php BB Group Server Load: 27 page(s) served in previous 5 minutes.
|