Ron Koenderink [Thu, 16 Aug 2007 03:03:22 +0000 (03:03 +0000)]
(ssize_t, pid_t) [_WIN32]: Back out the previous revision of unistd.h
and move to w32misc.h instead. Belong into sys/types.h but we can't
fix system headers.
Ron Koenderink [Wed, 15 Aug 2007 01:16:26 +0000 (01:16 +0000)]
Create w32misc.h to contain information that does not fit in Windows
equivalent include file.
(strptime) [_WIN32]: Add extern for WIN32 equivalent for strptime().
Ron Koenderink [Tue, 14 Aug 2007 03:11:26 +0000 (03:11 +0000)]
[_WIN32] (posix_mkdir): New.
[_WIN32] (mkdir): Use it. Last argument is no longer ignored, which
was a bug. Move declaration to unistd.h, which isn't quite right, but
works for us.
Fix fields checks for split tables:
(caseen): Remove.
(xufldhdr, deffld): Record only fields in this part in caflds[]. This
fixes the check for duplicate fields in parts other than the first.
(cafldspp): New, to record fields in previous parts.
(xundump): Initialize and finalize it.
(xufooter): Update it. Requires new parameter ca. Caller changed.
(fldval_must_match): Use it to do the right thing for split arrays.
(chkflds): Adapt for changed caflds[].
(chkflds): The check for missing fields was skipped for all parts of a
split table instead of for all but the final part.
(xufldhdr): ellipsis wasn't cleared for machine-readable input. This
broke reading machine-readable input after reading a split table
failed before seeing the last part. Luckily, callers never tried
that.
New home for stuff specific to Windows: src/lib/w32/
Move getopt.c getopt.h service.c from src/lib/gen/ there.
(lib/libw32.a): New.
(libs): Add it under Windows.
Ron Koenderink [Fri, 3 Aug 2007 01:47:02 +0000 (01:47 +0000)]
(fmttime2822) [_WIN32]: Replace localtime_s() with localtime().
Replace _snprintf_s() with _snprintf(). These secure functions are
not supported by MinGW yet.
(fl_sct_init, write_sects, file_sct_init, main): Do not initialize
sector and realm timestamps to current time. It's not useful, and it
facilitates attacks against the PRNG. This backs out fairland.c
rev. 1.27 and files.c rev. 1.31 and partly backs out files.c
rev. 1.38.
Store update disable flag in the game table to make it visible in
xdump:
(gamestr): New member game_upd_disable.
(game_ca): Update accordingly.
(game_ctrl_update): New.
(disa, enab): Use it.
(updates_disabled): Rewrite and move to game.c
(disablefil): Remove.
Ron Koenderink [Thu, 26 Jul 2007 01:59:32 +0000 (01:59 +0000)]
(fmttime2822): Changed return type for strftime() to size_t.
(fmttime2822) [_WIN32]: %T is not support option for strftime in WIN32
replaced with %H:%M:%S. Replaced %z in with +/-???? format for WIN32
as the default for WIN32 is the text description for timezone.
(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.
Remove the concept of thread priorities from empthread.h. Only LWP
supports priorities. Update synchronization used to rely on them,
which naturally worked only with LWP (#1504036). With that fixed, no
uses of priorities remained, but a minor bug did: players could starve
out threads with priorities below PP_PLAYER, i.e. delete_lostitems()
and player_kill_idle(). Closes #1458175:
(empth_create): Remove parameter prio. Callers changed. Also gets
rid of misleading comments in pthread.c and ntthread.c.
(PP_MAIN, PP_UPDATE, PP_SHUTDOWN, PP_SCHED, PP_TIMESTAMP, PP_PLAYER)
(PP_ACCEPT, PP_KILLIDLE): Remove.
(empth_init, empth_create) [EMPTH_LWP]: Pass priority 1.
(dispatch): Set player->command before acquiring play_lock, to make
sure the command is reliably aborted on update and shutdown. Before,
redirection output could block while player->command was still null,
letting players delay the update or shutdown indefinitely.
(dispatch): Rwlocks can hand out read locks while a write lock is
wanted. Unfair to writers, but possible. This lets commands run with
!player->aborted, which can then block on input and thus let players
delay the update or shutdown indefinitely. Avoid by spinning until
the update is done.
LWP failed to wake up threads sleeping in empth_sleep() while other
threads were runnable. This let players with a sufficiently fast
connection starve out system threads, including the update. Fix:
[EMPTH_LWP] (lwpWakeupSleep): External linkage.
[EMPTH_LWP] (lwpReschedule): Call it.
Replace incorrect uses of update_pending by update_running, fixing
buggy behavior while the update was trying to gain control:
(sct_do_upd_mob, shp_do_upd_mob, lnd_do_upd_mob, pln_do_upd_mob):
MOB_ACCESS mobility update was skipped.
(telegram_is_new): Fix recognition of new telegrams by timestamp.
(wu): Bulletins got misfiled as production reports.
(shp_nav): Sail path got ignored.
(setrel): Declaration of war failed silently with SLOW_WAR enabled.
Messages got suppressed.
(PR, mpr): Messages got misdirected to bulletins.