Rename play_lock back to update_lock

It was renamed to play_lock because it synchronized not just updates
but also shutdown.  Since the previous commit, it again only
synchronizes updates.  Rename it back.

Also move its initialization next to shutdown_lock's.
This commit is contained in:
Markus Armbruster 2012-03-27 20:06:35 +02:00
parent 49ae6a7b9d
commit 2503e41bd2
4 changed files with 9 additions and 12 deletions

View file

@ -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];

View file

@ -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;

View file

@ -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();

View file

@ -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