]> git.pond.sub.org Git - empserver/commit
Simplify checks whether player thread may sleep
authorMarkus Armbruster <armbru@pond.sub.org>
Tue, 28 Apr 2009 18:31:59 +0000 (20:31 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Mon, 30 Nov 2009 18:43:18 +0000 (19:43 +0100)
commit0a4d77e919028c54f5e99fdc883ec04bae92d882
treedca519bc006c2a931749f95318a8410f8f435eba
parentbd6d9d53a05159754cbbc15ad29688cee8cb25fa
Simplify checks whether player thread may sleep

A player thread may sleep on input or output, except:

(1) While it is executing a C_MOD command, it may only sleep on input.

(2) While it is being aborted by the update or shutdown, it may not
    sleep at all.

To find out whether a player thread may sleep on input, code has to
check condition (2).  It needs do to that in recvclient().

To find out whether it may sleep on output, it has to check both
conditions.  It needs to do that in pr_player() and upr_player().

The code tracked condition (1) in global variable play_lock_wanted.
It checked condition (2) by examining struct player member command.

Replace all that by new struct player member may_sleep.  Initialize it
in player_new(), update it in dispatch(), shutdwn() and update_run().
This makes the tests in recvclient(), pr_player() and upr_player()
obvious.  play_wrlock_wanted() is now unused, remove it.
include/player.h
include/server.h
src/lib/player/accept.c
src/lib/player/dispatch.c
src/lib/player/recvclient.c
src/lib/subs/pr.c
src/server/main.c
src/server/update.c