(player_kill_idle): Don't kill hung player threads. That code was
flawed. Firstly, when player_kill_idle() ran before the player thread could react to being aborted by update or shutdown, player_kill_idle() incorrectly diagnosed it as hung. Secondly, terminating hung threads leaks resources and can leave a stale play_lock behind. It could perhaps even corrupt game state. It might salvage some scenarios, but makes others worse. Not worth it.
This commit is contained in:
parent
d500a7071c
commit
043015e829
2 changed files with 4 additions and 15 deletions
|
@ -51,29 +51,19 @@ player_kill_idle(void *unused)
|
||||||
while (1) {
|
while (1) {
|
||||||
empth_sleep(now + 60);
|
empth_sleep(now + 60);
|
||||||
time(&now);
|
time(&now);
|
||||||
/*if (update_pending) */
|
|
||||||
/*continue; */
|
|
||||||
for (p = player_next(0); p != 0; p = player_next(p)) {
|
for (p = player_next(0); p != 0; p = player_next(p)) {
|
||||||
if (p->state == PS_SHUTDOWN) {
|
if (p->state == PS_SHUTDOWN) {
|
||||||
/* player thread hung */
|
/*
|
||||||
/* FIXME but for how long? unknown if shut down elsewhere! */
|
* Player thread hung or just aborted by update or
|
||||||
/* FIXME this can leave stale update_lock behind! */
|
* shutdown, we can't tell.
|
||||||
empth_terminate(p->proc);
|
*/
|
||||||
p = player_delete(p);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (p->curup + max_idle * 60 < now) {
|
if (p->curup + max_idle * 60 < now) {
|
||||||
p->state = PS_SHUTDOWN;
|
p->state = PS_SHUTDOWN;
|
||||||
/* giving control to another thread while
|
|
||||||
* in the middle of walking player list is
|
|
||||||
* not a good idea at all. Sasha */
|
|
||||||
p->aborted++;
|
p->aborted++;
|
||||||
pr_flash(p, "idle connection terminated\n");
|
pr_flash(p, "idle connection terminated\n");
|
||||||
empth_wakeup(p->proc);
|
empth_wakeup(p->proc);
|
||||||
/* go to sleep because player thread
|
|
||||||
could vandalize a player list */
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -385,7 +385,6 @@ shutdwn(int sig)
|
||||||
empth_wakeup(p->proc);
|
empth_wakeup(p->proc);
|
||||||
}
|
}
|
||||||
empth_rwlock_wrlock(play_lock);
|
empth_rwlock_wrlock(play_lock);
|
||||||
/* rely on player_kill_idle() for killing hung player threads */
|
|
||||||
if (sig)
|
if (sig)
|
||||||
logerror("Server shutting down on signal %d", sig);
|
logerror("Server shutting down on signal %d", sig);
|
||||||
else
|
else
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue