(dispatch): Rwlocks can hand out read locks while a write lock is

wanted.  Unfair to writers, but possible.  This lets commands run with
!player->aborted, which can then block on input and thus let players
delay the update or shutdown indefinitely.  Avoid by spinning until
the update is done.
This commit is contained in:
Markus Armbruster 2007-07-22 17:06:00 +00:00
parent bca365c485
commit f850968883

View file

@ -88,6 +88,16 @@ dispatch(char *buf, char *redir)
pr("Command not implemented\n"); pr("Command not implemented\n");
return 0; return 0;
} }
/*
* Rwlocks can hand out read locks while a write lock is wanted.
* Unfair to writers, but possible. This lets commands run with
* !player->aborted, which can then block on input and thus delay
* the update indefinitely. We could avoid that by setting
* player->aborted here, but spinning until the update is done is
* nicer to players.
*/
while (play_wrlock_wanted)
empth_yield();
empth_rwlock_rdlock(play_lock); empth_rwlock_rdlock(play_lock);
if (redir) { if (redir) {
prredir(redir); prredir(redir);