]> git.pond.sub.org Git - empserver/commit
Change login command kill to kill less ruthlessly
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 18 Mar 2012 17:30:39 +0000 (18:30 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Thu, 26 Apr 2012 17:57:19 +0000 (19:57 +0200)
commiteb25be08d4812e51bac539494823034a1aaf69bd
tree3eb64e2b948d897e7416eb97e9b76362041274d3
parent918f3ec6ae953ab2c17c14399a4bf84849edc08c
Change login command kill to kill less ruthlessly

The victim's connection closes without any explanation.  Output may be
lost.  This is because kill_cmd() kills by calling io_shutdown(),
which shuts down the socket and drains the I/O queues.

How this makes the victim's thread terminate is a bit subtle: shutting
down the socket makes it ready.  If the victim's thread is waiting for
I/O, it wakes up.  Since all further reads return EOF, and all further
writes fail, the command terminates quickly (short of inifinite loop
bugs), then the command loop, and finally the thread.

To make kill behave more nicely, change kill_cmd() to work exactly
like server shutdown: send a flash message to the victim, set his EOF
indicator, abort the command, forbid sleeping on I/O, wake up the
victim's thread.  Just as reliable, but doesn't lose output.

If the victim's client fails to close his connection, the victim's
thread may still linger in state PS_SHUTDOWN for up to
login_grace_time (default 120s).  An attacker could try to use that to
make the server run out of file descriptors or memory, but simply
connecting achieves the same effect more cheaply.
src/lib/player/login.c