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:
parent
49ae6a7b9d
commit
2503e41bd2
4 changed files with 9 additions and 12 deletions
|
@ -38,7 +38,7 @@
|
||||||
#define UPDATE_TIME_LEN 16
|
#define UPDATE_TIME_LEN 16
|
||||||
|
|
||||||
extern int shutdown_pending;
|
extern int shutdown_pending;
|
||||||
extern empth_rwlock_t *play_lock;
|
extern empth_rwlock_t *update_lock;
|
||||||
extern empth_rwlock_t *shutdown_lock;
|
extern empth_rwlock_t *shutdown_lock;
|
||||||
extern int update_running;
|
extern int update_running;
|
||||||
extern time_t update_time[UPDATE_TIME_LEN];
|
extern time_t update_time[UPDATE_TIME_LEN];
|
||||||
|
|
|
@ -87,7 +87,7 @@ dispatch(char *buf, char *redir)
|
||||||
player->may_sleep = command->c_flags & C_MOD
|
player->may_sleep = command->c_flags & C_MOD
|
||||||
? PLAYER_SLEEP_ON_INPUT : PLAYER_SLEEP_FREELY;
|
? PLAYER_SLEEP_ON_INPUT : PLAYER_SLEEP_FREELY;
|
||||||
player->command = command;
|
player->command = command;
|
||||||
empth_rwlock_rdlock(play_lock);
|
empth_rwlock_rdlock(update_lock);
|
||||||
if (redir) {
|
if (redir) {
|
||||||
prredir(redir);
|
prredir(redir);
|
||||||
uprnf(buf);
|
uprnf(buf);
|
||||||
|
@ -109,7 +109,7 @@ dispatch(char *buf, char *redir)
|
||||||
CANT_REACH();
|
CANT_REACH();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
empth_rwlock_unlock(play_lock);
|
empth_rwlock_unlock(update_lock);
|
||||||
player->command = NULL;
|
player->command = NULL;
|
||||||
if (player->may_sleep != PLAYER_SLEEP_NEVER || !io_eof(player->iop))
|
if (player->may_sleep != PLAYER_SLEEP_NEVER || !io_eof(player->iop))
|
||||||
player->may_sleep = PLAYER_SLEEP_FREELY;
|
player->may_sleep = PLAYER_SLEEP_FREELY;
|
||||||
|
|
|
@ -78,7 +78,7 @@ static void loc_NTInit(void);
|
||||||
* Lock to synchronize player threads with update.
|
* Lock to synchronize player threads with update.
|
||||||
* Update holds it exclusive, commands hold it shared.
|
* 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.
|
* Lock to synchronize player threads with shutdown.
|
||||||
* Shutdown holds it exclusive, player threads in state PS_PLAYING
|
* Shutdown holds it exclusive, player threads in state PS_PLAYING
|
||||||
|
@ -380,8 +380,9 @@ start_server(int flags)
|
||||||
if (journal_startup() < 0)
|
if (journal_startup() < 0)
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
|
update_lock = empth_rwlock_create("Update");
|
||||||
shutdown_lock = empth_rwlock_create("Shutdown");
|
shutdown_lock = empth_rwlock_create("Shutdown");
|
||||||
if (!shutdown_lock)
|
if (!update_lock || !shutdown_lock)
|
||||||
exit_nomem();
|
exit_nomem();
|
||||||
|
|
||||||
market_init();
|
market_init();
|
||||||
|
|
|
@ -74,10 +74,6 @@ update_init(void)
|
||||||
if (update_get_schedule() < 0)
|
if (update_get_schedule() < 0)
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
play_lock = empth_rwlock_create("Update");
|
|
||||||
if (!play_lock)
|
|
||||||
exit_nomem();
|
|
||||||
|
|
||||||
dp = player_new(-1);
|
dp = player_new(-1);
|
||||||
if (!dp)
|
if (!dp)
|
||||||
exit_nomem();
|
exit_nomem();
|
||||||
|
@ -207,17 +203,17 @@ update_run(void)
|
||||||
empth_wakeup(p->proc);
|
empth_wakeup(p->proc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
empth_rwlock_wrlock(play_lock);
|
empth_rwlock_wrlock(update_lock);
|
||||||
if (*pre_update_hook) {
|
if (*pre_update_hook) {
|
||||||
if (run_hook(pre_update_hook, "pre-update")) {
|
if (run_hook(pre_update_hook, "pre-update")) {
|
||||||
empth_rwlock_unlock(play_lock);
|
empth_rwlock_unlock(update_lock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
update_running = 1;
|
update_running = 1;
|
||||||
update_main();
|
update_main();
|
||||||
update_running = 0;
|
update_running = 0;
|
||||||
empth_rwlock_unlock(play_lock);
|
empth_rwlock_unlock(update_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue