empserver/include
Markus Armbruster 49ae6a7b9d Fix synchronization between shutdown and player threads
shutdwn() sets the EOF indicator, aborts the running command, if any,
forbids sleeping on I/O and wakes up the player thread, for all player
threads in state PS_PLAYING.  It takes play_lock to prevent new
commands from running.  It then waits up to 3s for player threads to
terminate, by polling player_next(), to let output buffers drain.

Issues:

1. Polling is lame.

2. New player threads can still enter state PS_PLAYING.  They'll block
   as soon as they try to run a command.  Somehwat unclean.

3. We can exit before all player threads left state PS_PLAYING, losing
   a treasury update, play time update, and log entries.  Could happen
   when player threads blocked on output until commit 90b3abc5 fixed
   that; its commit message describes the bug's impact in more detail.
   Since then, the bug shouldn't bite in practice, because player
   threads should leave state PS_PLAYING quickly.

Fix by introducing shutdown_lock: player threads in state PS_PLAYING
hold it shared, shutdwn() takes it exclusive, instead of play_lock.
Takes care of the issues as follows:

3. shutdwn() waits until all player threads left state PS_PLAYING, no
   matter how long it takes them.

2. New player threads block before entering state PS_PLAYING.

1. shutdwn() still polls up to 3s for player threads to terminate.
   Still lame.  Left for another day.
2012-04-26 20:05:28 +02:00
..
budg.h License upgrade to GPL version 3 or later 2011-04-12 21:20:58 +02:00
com.h Clean up c_permit values of deity commands 2012-02-25 11:22:36 +01:00
combat.h License upgrade to GPL version 3 or later 2011-04-12 21:20:58 +02:00
commands.h Clean up superfluous include of nsc.h in prototypes.h 2011-04-14 19:46:05 +02:00
commodity.h License upgrade to GPL version 3 or later 2011-04-12 21:20:58 +02:00
damage.h License upgrade to GPL version 3 or later 2011-04-12 21:20:58 +02:00
distribute.h License upgrade to GPL version 3 or later 2011-04-12 21:20:58 +02:00
econfig-spec.h Separate max_idle_visitor from max_idle 2012-04-26 19:57:19 +02:00
empio.h io_shutdown() is now unused, remove 2012-04-26 19:57:19 +02:00
empobj.h Verify table uid sanity more tightly 2011-06-25 16:54:29 +02:00
empthread.h License upgrade to GPL version 3 or later 2011-04-12 21:20:58 +02:00
file.h Split ef_verify() into ef_verify_config(), ef_verify_state() 2011-07-10 21:17:01 +02:00
game.h Update known contributors comments 2011-04-14 20:21:23 +02:00
ioqueue.h License upgrade to GPL version 3 or later 2011-04-12 21:20:58 +02:00
item.h Better document how .config must match compiled-in UIDs 2011-06-25 16:45:29 +02:00
journal.h New journal event "output" 2011-04-14 20:21:21 +02:00
land.h Update known contributors comments 2011-04-14 20:21:23 +02:00
loan.h License upgrade to GPL version 3 or later 2011-04-12 21:20:58 +02:00
lost.h License upgrade to GPL version 3 or later 2011-04-12 21:20:58 +02:00
lwp.h Update known contributors comments 2011-04-14 20:21:23 +02:00
map.h Clean up move_ground()'s parsing of DIR_MAP 2011-04-14 20:21:23 +02:00
match.h License upgrade to GPL version 3 or later 2011-04-12 21:20:58 +02:00
misc.h Update known contributors comments 2011-04-14 20:21:23 +02:00
mission.h License upgrade to GPL version 3 or later 2011-04-12 21:20:58 +02:00
nat.h Move setting nat_cnam, nat_pnam into nat_reset() 2011-12-29 11:47:06 +01:00
news.h License upgrade to GPL version 3 or later 2011-04-12 21:20:58 +02:00
nsc.h A few comment fixes for nsc.[ch] file.[ch] 2011-06-25 16:45:31 +02:00
nuke.h License upgrade to GPL version 3 or later 2011-04-12 21:20:58 +02:00
optlist.h Update known contributors comments 2011-04-14 20:21:23 +02:00
path.h Remove p_mode, use MOB_FLY and MOB_SAIL instead 2011-04-12 21:51:32 +02:00
plague.h License upgrade to GPL version 3 or later 2011-04-12 21:20:58 +02:00
plane.h Update known contributors comments 2011-04-14 20:21:23 +02:00
player.h Revise nation status command permissions 2012-02-25 11:24:32 +01:00
power.h License upgrade to GPL version 3 or later 2011-04-12 21:20:58 +02:00
product.h License upgrade to GPL version 3 or later 2011-04-12 21:20:58 +02:00
proto.h License upgrade to GPL version 3 or later 2011-04-12 21:20:58 +02:00
prototypes.h Document the header for empmod.c and trdsub.c in prototypes.h 2012-04-26 19:57:19 +02:00
queue.h License upgrade to GPL version 3 or later 2011-04-12 21:20:58 +02:00
retreat.h License upgrade to GPL version 3 or later 2011-04-12 21:20:58 +02:00
sect.h Better document how .config must match compiled-in UIDs 2011-06-25 16:45:29 +02:00
server.h Fix synchronization between shutdown and player threads 2012-04-26 20:05:28 +02:00
service.h License upgrade to GPL version 3 or later 2011-04-12 21:20:58 +02:00
ship.h Update known contributors comments 2011-04-14 20:21:23 +02:00
tel.h Factor mailbox_create() out of nat_reset() and files.c 2011-12-29 11:47:07 +01:00
trade.h License upgrade to GPL version 3 or later 2011-04-12 21:20:58 +02:00
treaty.h Update known contributors comments 2011-04-14 20:21:23 +02:00
types.h Update known contributors comments 2011-04-14 20:21:23 +02:00
unit.h Fix navigate and march to find paths longer than 7 sectors again 2011-07-12 07:12:57 +02:00
update.h License upgrade to GPL version 3 or later 2011-04-12 21:20:58 +02:00
version.h License upgrade to GPL version 3 or later 2011-04-12 21:20:58 +02:00
xdump.h Update known contributors comments 2011-04-14 20:21:23 +02:00
xy.h Move xysize_range(), xydist_range() to xy.c and xy.h 2011-04-14 20:21:21 +02:00