(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:
parent
f850968883
commit
8fa3ba1b60
1 changed files with 2 additions and 2 deletions
|
@ -98,13 +98,13 @@ dispatch(char *buf, char *redir)
|
||||||
*/
|
*/
|
||||||
while (play_wrlock_wanted)
|
while (play_wrlock_wanted)
|
||||||
empth_yield();
|
empth_yield();
|
||||||
|
player->command = command;
|
||||||
empth_rwlock_rdlock(play_lock);
|
empth_rwlock_rdlock(play_lock);
|
||||||
if (redir) {
|
if (redir) {
|
||||||
prredir(redir);
|
prredir(redir);
|
||||||
uprnf(buf);
|
uprnf(buf);
|
||||||
pr("\n");
|
pr("\n");
|
||||||
}
|
}
|
||||||
player->command = command;
|
|
||||||
switch (command->c_addr()) {
|
switch (command->c_addr()) {
|
||||||
case RET_OK:
|
case RET_OK:
|
||||||
player->btused += command->c_cost;
|
player->btused += command->c_cost;
|
||||||
|
@ -121,6 +121,6 @@ dispatch(char *buf, char *redir)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
empth_rwlock_unlock(play_lock);
|
empth_rwlock_unlock(play_lock);
|
||||||
player->command = 0;
|
player->command = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue