(dispatch): Set player->command before acquiring play_lock, to make

sure the command is reliably aborted on update and shutdown.  Before,
redirection output could block while player->command was still null,
letting players delay the update or shutdown indefinitely.
This commit is contained in:
Markus Armbruster 2007-07-22 17:23:34 +00:00
parent f850968883
commit 8fa3ba1b60

View file

@ -98,13 +98,13 @@ dispatch(char *buf, char *redir)
*/
while (play_wrlock_wanted)
empth_yield();
player->command = command;
empth_rwlock_rdlock(play_lock);
if (redir) {
prredir(redir);
uprnf(buf);
pr("\n");
}
player->command = command;
switch (command->c_addr()) {
case RET_OK:
player->btused += command->c_cost;
@ -121,6 +121,6 @@ dispatch(char *buf, char *redir)
break;
}
empth_rwlock_unlock(play_lock);
player->command = 0;
player->command = NULL;
return 0;
}