From d8fbfda100d8151c472210a73705469e1985247b Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sun, 21 Jan 2007 12:04:16 +0000 Subject: [PATCH] (shutdwn): Take exclusive update lock for shutdown. This makes the shutdown block until all aborted commands terminated and gave up their lock. Remove the cheesy one second wait for commands to finish. This also locks out further commands to execute during shutdown. However, it also makes it impossible to kill hung player threads here. Rely on player_kill_idle() for that. That doesn't quite work right now, because it leaves a stale shared lock behind, which blocks shutdown. --- src/server/main.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/server/main.c b/src/server/main.c index 7d07e740d..ad527c4fd 100644 --- a/src/server/main.c +++ b/src/server/main.c @@ -366,7 +366,6 @@ void shutdwn(int sig) { struct player *p; - time_t now; logerror("Shutdown commencing (cleaning up threads.)"); @@ -381,16 +380,8 @@ shutdwn(int sig) } empth_wakeup(p->proc); } - - time(&now); - empth_sleep(now + 1); - - for (p = player_next(0); p != 0; p = player_next(p)) { - p->state = PS_KILL; - p->aborted++; - empth_terminate(p->proc); - p = player_delete(p); - } + empth_rwlock_wrlock(update_lock); + /* rely on player_kill_idle() for killing hung player threads */ if (sig) logerror("Server shutting down on signal %d", sig); else -- 2.43.0