(lwpInitSystem): Stack checking doesn't work and is not necessary for
main thread; clear LWP_STACKCHECK.
(lwpStackCheck): Log stack overflow/underflow and abort.
Ron Koenderink [Wed, 16 Mar 2005 02:39:51 +0000 (02:39 +0000)]
(loc_Ctrl_C_Handler,loc_Exit_Handler) [_WIN32]: Process other
exit methods in the same way as ctrl-c. Change loc_Ctrl_C_Handler()
to loc_Exit_Handler() to reflect changed functionality.
(shutdwn): Rev. 1.51 broke the Linux pthread hack. It is unclear what
this hack is trying to achieve. It never worked without -d, because
mainpid got assigned the wrong pid. It doesn't make sense with recent
versions of Linux pthreads, which use the same PID for all threads, as
required by POSIX. Remove. Closes #1161397.
Ron Koenderink [Tue, 15 Mar 2005 18:19:07 +0000 (18:19 +0000)]
(service_stoppped,stop_service,loc_Ctrl_C_Handler,
empth_request_shutdown,loc_BlockMainThread,empth_init,
service_ctrl_handler) [_WIN32]: Remove the Windows Build UI and
replace with Ctrl-c signal trap. The shutdown event that was used for
STOPPING the service is now used for both foreground and background
(service) modes of operation. Also move the shutdown event from service
code to empth_t library.
Marc Olzheim [Tue, 15 Mar 2005 18:05:16 +0000 (18:05 +0000)]
Don't try running 'cvs co' more than 5 times, since it might be a local
problem as well. Document NIGHTLY_SKIP_STEP=PATCH. Update to the currently
running script.
Ron Koenderink [Sun, 13 Mar 2005 21:53:23 +0000 (21:53 +0000)]
(main,print_usage) [_WIN32]: Add the ability to enable
empire thread debugging for Windows build.
(empth_select) [_WIN32]: Fix empth_select() so can be aborted.
The bug was that a command would not be aborted during an update.
The problem was select() was not interrupt by the setting of the
signalling wakeup event. Fix by replacing the select() with
WSAEventSelect().
(empth_exit) [_WIN32]:
Fix the shutdown sequence for Windows build to be running in
empth_t context. Add a loc_RunThisThread() in empth_exit()
before starting the shutdown() sequence.
Write pid file, like a good daemon. Thanks to Daniel O'Connor for the
initial patch.
(create_pidfile, pidfname): New.
(start_server): Create pid file.
(finish_server): Remove pid file.
(main) [__linux__ && _EMPTH_POSIX]: Don't hack pid into argv[0].
Recent versions of Linux pthreads no longer show multiple PIDs, and
deities can get the PID fro the pid file anyway.
(finish_server): New, factored out of termination code. Fixes two
places in service_main() that lacked close_files().
(close_files, loc_NTTerm): Static linkage.
(service_main,main,shutdown,empth_exit,service_stopped) [_WIN32]:
Add shutdown Event to allow the service to shutdown.
When SERVICE_STOPPED is passed to SetServiceStatus() all
threads are kills this prevents shutdown() from executing.
The shutdown Event is used to block the service_main thread until
the stopping of the service is started. After the shutdown() is
complete then the SetServiceStatus() is called.
Merge pre-4-2-20-invasive. Summary of changes:
* Acquire resources before daemonizing, fail in foreground
* Initialize threads and signals after daemonizing
* Make most file names relative to data directory
* emp_server and files make it their working directory
* emp_config() no longer screws up some file names
* Missing or incorrect econfig is now fatal
* Don't log to default log file when econfig changes it
(init_server, start_server): Move signal and thread initialization
from init_server() to start_server(), and service startup next to its
Unix equivalent disassoc(). This way, threading is always initialized
after daemonizing, which is simpler and more portable.
(disassoc): src/lib/player/accept.c rev. 1.18.2.1 broke the server
when it runs as daemon, because it relies on player_socket remaining
open across disassoc(). Change disassoc() to only close file
descriptors 0..2 instead of 0..9. By the way, it should really
redirect 0..2 to /dev/null instead.
(empfile, teldir, motdfil, downfil, disablefil, telfil, annfil)
(banfil, authfil, timestampfil): Make file names relative to DATADIR.
(main): emp_server and files change to the data directory. fairland
has to write newcap_script to the initial current directory, so it
keeps it and makes file names relative to DATADIR absolute.
(fixup_files): Nothing to do, remove. This fixes the following bug:
fixup_files() formed file names by appending ep->name instead of the
base name of ep->file to datadir. Thus, fixup_files() changed file
names even when datadir had the compiled-in value. When emp_config()
couldn't open econfig, it failed to call fixup_files(), and different
file names got used. Note that with this revision the file names
revert to the names used before fixup_files() was introduced. Closes
#1146080.
(print_config): Printing file names as comments is not really useful,
remove.
(otherfiles, ofiles): Unused, remove.
(emp_config, main): Previously, pconfig had to call emp_config() even
when it didn't want to read econfig, just to run fixup_files(). This
is no longer necessary. Simplify.
(dflt_econfig): New.
(emp_config): Use it when argument is NULL. This simplifies callers
except pconfig's main(), which now has to suppress reading the default
file. Also fix callers to check the return value. Previously, a typo
could easily start a grossly misconfigured program, with potentially
disastrous results.
(player_init, player_accept): Move socket bind and listen from
player_accept() to player_init(). Acquiring resources during
initialization allows to exit unsuccessfully on errors. Previously,
the daemon detached itself (exiting successfully), then failed in the
background.
(player_socket): New.
Ron Koenderink [Sun, 6 Mar 2005 20:58:48 +0000 (20:58 +0000)]
(service_main) [_WIN32]: Remove the command line processing.
The secondary command line processing was adding significant
complexity for minimial gain. Now all the command line arguments
can be prequalified during the installation of the service.
(service_main) [_WIN32]: Move the initialization (init_server())
so logerror() will go to the file instead of stderr.
Ron Koenderink [Sun, 6 Mar 2005 20:08:52 +0000 (20:08 +0000)]
(main,service_main) [_WIN32]: Remove printf for errors
during startup, as logerror will print to stderr or to log file.
Remove logerror for successful installation and removal.
Ron Koenderink [Sun, 6 Mar 2005 19:53:14 +0000 (19:53 +0000)]
(main,service_main) [_WIN32]: Fix config_file for WIN32.
(main,service_main,empth_exit) [_WIN32]: Add daemon flag.
Separate the debug_flag into two separate flags, one for
debugging (debug) and controlling the daemon processing
(daemon).
(start_server, main, service_main): Call emp_config() earlier.
(main): Call loginit() later, after emp_config(). Previously, the
program logged to the default datadir until emp_config().
(init_server, start_sever): Split start_server() into initialization
and actual startup. Move initialization before disassoc().
(main, init_server): Log server startup only after initialization is
complete.
Ron Koenderink [Wed, 2 Mar 2005 23:53:10 +0000 (23:53 +0000)]
(nreport, filereport, ncache, addfree, findfree, delete_old_news)
(init_nreport, update_main, start_server): Switch news to be sorted
list with all new news items added at the end of the list. The
removal of expired news items is done at update time. Closes #766755.
Ron Koenderink [Wed, 2 Mar 2005 12:47:15 +0000 (12:47 +0000)]
(wrmakesrc,wripglob,wrgamesdef,info,apro,mobupdate,rea,turn
upda,ef_open,logerror,emp_config,match_user,show_motd,gamedown,
typed_wu,delete_old_announcements,mobility_check,mobility_init,
allocate_memory,write_newcap_script,main,files,fairland,doconfig,)
[_WIN32]: Switchback to default mode of text.
"t" (text) is not included the ISO/ANSI C standard but "b" (binary)
is included.
First step towards generalizing NSC_TYPEID to arbitrary dictionaries.
(nsc_cat) New category NSC_ID.
(nstr_comp): Resolve identifiers instead of relying on nstr_comp_val()
and nstr_coerce_val().
(valstr, nstr_coerce_val): Remove valstr member val_as_type.
(nstr_parse_val, nstr_match_ca, nstr_match_val, nstr_resolve_id)
(nstr_resolve_sel, nstr_mkselval): New.
(nstr_comp_val): Rewrite using the above.
(nullify_objects): Simply use all of bigcity_dchr. Using only parts
is confusing.
(bigcity_dchr): Fix initializer for d_maxpop.
(dchr): The previous revision accidentally changed maximum population
of sanctuaries, plains, sea and wasteland. Revert the former two.
The latter are not used, but the new max population of zero makes more
sense, so keep it.
Ron Koenderink [Mon, 21 Feb 2005 18:17:11 +0000 (18:17 +0000)]
(main): Move loginit() to after the getopt(), so the -D option will
take affect for the log file. Otherwise the server.log will be in
default data directory compiled into the server.
Marc Olzheim [Mon, 21 Feb 2005 17:17:16 +0000 (17:17 +0000)]
Update patch for include/prototypes.h:1.66
src/lib/commands/mfir.c:1.21 src/lib/commands/sabo.c:1.10
src/lib/update/human.c:1.15 No functional changes.
(total_work): Remove redundant conversion to int.
(total_work): New parameter maxpop. Callers changed.
(newe, prod): Use total_work(). Old code failed to limit military
workers, thus didn't match the update.
(do_feed): Simplify.
(prod): Several columns were too narrow, and didn't align properly for
large values. Remove column wkfc to make space, widen other columns.
Columns use2, use3 and max2, max3 lack separating space on the left
for large values, which don't occur in normal game configurations.
(max_population): New, factored out of max_pop().
(max_pop): Use it. Don't support null argument anymore.
(nati, gen_power): Use max_population() instead of max_pop() with null
argument.
(show_sect_stats): Use max_population() to simplify the code.
(prod, upd_buildeff): Use max_population() to get correct new maximum
population for limiting work when tearing down a big city.
Previously, this was broken in upd_buildeff(). In prod(), it was
broken when the new designation had odd maximum population, which
should not occur.