diff --git a/include/server.h b/include/server.h index 0729d554..fea0a080 100644 --- a/include/server.h +++ b/include/server.h @@ -38,7 +38,7 @@ #define UPDATE_TIME_LEN 16 extern int shutdown_pending; -extern empth_rwlock_t *play_lock; +extern empth_rwlock_t *update_lock; extern empth_rwlock_t *shutdown_lock; extern int update_running; extern time_t update_time[UPDATE_TIME_LEN]; diff --git a/src/lib/player/dispatch.c b/src/lib/player/dispatch.c index 73f5051c..c2de9a57 100644 --- a/src/lib/player/dispatch.c +++ b/src/lib/player/dispatch.c @@ -87,7 +87,7 @@ dispatch(char *buf, char *redir) player->may_sleep = command->c_flags & C_MOD ? PLAYER_SLEEP_ON_INPUT : PLAYER_SLEEP_FREELY; player->command = command; - empth_rwlock_rdlock(play_lock); + empth_rwlock_rdlock(update_lock); if (redir) { prredir(redir); uprnf(buf); @@ -109,7 +109,7 @@ dispatch(char *buf, char *redir) CANT_REACH(); break; } - empth_rwlock_unlock(play_lock); + empth_rwlock_unlock(update_lock); player->command = NULL; if (player->may_sleep != PLAYER_SLEEP_NEVER || !io_eof(player->iop)) player->may_sleep = PLAYER_SLEEP_FREELY; diff --git a/src/server/main.c b/src/server/main.c index 267de1cd..f67d9b25 100644 --- a/src/server/main.c +++ b/src/server/main.c @@ -78,7 +78,7 @@ static void loc_NTInit(void); * Lock to synchronize player threads with update. * Update holds it exclusive, commands hold it shared. */ -empth_rwlock_t *play_lock; +empth_rwlock_t *update_lock; /* * Lock to synchronize player threads with shutdown. * Shutdown holds it exclusive, player threads in state PS_PLAYING @@ -380,8 +380,9 @@ start_server(int flags) if (journal_startup() < 0) exit(1); + update_lock = empth_rwlock_create("Update"); shutdown_lock = empth_rwlock_create("Shutdown"); - if (!shutdown_lock) + if (!update_lock || !shutdown_lock) exit_nomem(); market_init(); diff --git a/src/server/update.c b/src/server/update.c index dd6f2acb..5afdb9ab 100644 --- a/src/server/update.c +++ b/src/server/update.c @@ -74,10 +74,6 @@ update_init(void) if (update_get_schedule() < 0) exit(1); - play_lock = empth_rwlock_create("Update"); - if (!play_lock) - exit_nomem(); - dp = player_new(-1); if (!dp) exit_nomem(); @@ -207,17 +203,17 @@ update_run(void) empth_wakeup(p->proc); } } - empth_rwlock_wrlock(play_lock); + empth_rwlock_wrlock(update_lock); if (*pre_update_hook) { if (run_hook(pre_update_hook, "pre-update")) { - empth_rwlock_unlock(play_lock); + empth_rwlock_unlock(update_lock); return; } } update_running = 1; update_main(); update_running = 0; - empth_rwlock_unlock(play_lock); + empth_rwlock_unlock(update_lock); } int