empth_init(), because writing calls empth_self(). Move call of
journal_startup().
(ef_close_srv, finish_server, panic): Move call of journal_shutdown()
for symmetry.
(journal_reopen): New.
(main): Use it. Fixes failure to obey !keep_journal.
(journal_open): Internal linkage, changed semantics and return value.
Callers changed.
(journal_close): One caller left, inline and remove.
shutdown block until all aborted commands terminated and gave up their
lock. Remove the cheesy one second wait for commands to finish. This
also locks out further commands to execute during shutdown. However,
it also makes it impossible to kill hung player threads here. Rely on
player_kill_idle() for that. That doesn't quite work right now,
because it leaves a stale shared lock behind, which blocks shutdown.
beginning of function instead using the leader. The leader
becomes unknown when stopping or unit list becomes
empty. This broke printing the path for ships. Broken
in rev 1.43.
(shutdown_initiate): New.
(shut): Use it. Shutdown in zero minutes no longer cancels the
shutdown, it just works. Use negative argument to cancel. Logging is
less detailed.
(shutdown_sequence): Internal linkage.
(pr_wall): All callers prefix text it with the same header. Move it
into the function.
continued to exist. Fortunately, both shark and collect refused to
touch it. fina() and repa() oopsed in loan_owed(), and recovered by
assuming (incorrectly!) a plausible debt. Before trdsub.c rev. 1.7,
fina() catched and logged the bug, and ignored the loan, and repa()
computed a ridiculous debt.
(update_trigger): New.
(force, zdon): Use it.
(update_sem, update_force): Internal linkage.
(update_trigger, update_force): Passing a pointer to static storage as
thread argument is racy. Use dynamic allocation.
when update_pending. This makes no sense. The map is updated in
memory and not calling writemap() only delays the write back to disk.
Remove the conditional.
(check_all_markets): No longer a thread entry point. Remove the
parameter. Remove *player setup. Don't terminate the thread when
done.
(market_update): Call check_all_markets() instead of running it in its
own thread. Set up *player for it.
(market_init): Create the fused update thread instead of the update
wait thread.
(update_main): No longer a thread entry point. Remove the parameter.
Remove *player setup. Don't terminate the thread when done.
(update_pending): Move to src/server/update.c.
(update_wait): Call update_main() instead of running it in its own
thread. Set up *player for it.
(update_init): Create the fused update thread instead of the update
wait thread.
resolving #1458175 and #1504036):
(update_lock): New.
(update_shed): Initialize it.
(update_wait, dispatch): Take exclusive update_lock around the update,
shared update_lock around commands. This makes the update block until
all aborted commands terminated and gave up their lock. Remove the
cheesy and unsafe two second wait for commands to finish. It also
makes player threads block before executing commands while the update
is pending, removing the need to fail commands then. So don't.
(loc_RunThisThread, empth_init, empth_create, empth_wait_for_signal)
[EMPTH_W32]: Remove some incorrect references to semaphones
in the comments. No functional changes.
This is more robust than using bp_put_item() for those elements of
vec[] that the call may change. The old code missed some changes:
upd_buildeff() changing population when tearing down a big city,
enlist(), and produce(). The first two should have been harmless, the
last one made budget mispredict repairs when required materials were
produced in the same update.