Commit graph

782 commits

Author SHA1 Message Date
8169a0a031 A backup script for pre_update_hook. 2005-03-12 17:31:55 +00:00
7d71984932 (pre_update_hook): New configuration key.
(update_wait): Implement it.
(run_hook): New.
2005-03-12 17:24:57 +00:00
f12649c3da 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.
2005-03-12 16:45:43 +00:00
3f472fc729 (finish_server): New, factored out of termination code. Fixes two
places in service_main() that lacked close_files().
(close_files, loc_NTTerm): Static linkage.
2005-03-12 16:28:28 +00:00
Ron Koenderink
b915edd13c (start_server) [_WIN32]: Put #ifndef _WIN32 around act.
This was missed with the [!POSIXSIGNALS]: changes.
2005-03-12 16:10:49 +00:00
0595ff4d4e Indentation fixes. 2005-03-12 15:05:23 +00:00
d8daa5f67d (init_server, start_server): Move start log message to start_server(),
where it belongs.
2005-03-12 15:04:37 +00:00
7eb2fe571e (logerror): Log to stderr as well. Fix potential buffer overflows.
(oops): Let logerror() supply the newline.
2005-03-12 15:03:31 +00:00
8f40f5ad6d [DO_EFF_MEM_CHECKING]: Dead for some ten years. Bury. 2005-03-12 13:40:24 +00:00
590cfe674a [GODZILLA]: Incomplete, unused, remove. 2005-03-12 13:27:13 +00:00
0e68d68390 (main, empth_start): Don't bother to catch SIGUSR1. Use SIGINT or
SIGTERM to shutdown the server.
2005-03-12 12:30:58 +00:00
09b481b30a [!POSIXSIGNALS]: Thoroughly obsolete, remove. This also gets rid of
an odd case where signals were not catched when debugging.

(main, empth_start): Using sa_handler with SA_SIGINFO is wrong.
Simply don't set SA_SIGINFO; the additional signal information is not
used anyway.
2005-03-12 12:20:50 +00:00
Ron Koenderink
014d005c69 (service_main,main,shutdown) [_WIN32]: Add missing loc_NTTerm().
(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.
2005-03-12 04:35:09 +00:00
6c7f707b76 [hpux] (srandom, random): HP-UX has had these for ages. Remove. 2005-03-11 17:05:19 +00:00
9cd463f8bc (main): Fix seeding of PRNG broken in rev. 1.22. 2005-03-11 17:03:07 +00:00
256724c39f (multifire, new): Reseeding the PRNG with the current time is not a
good idea.  Letting players trigger it is an extraordinarily bad idea.
Remove.
2005-03-11 17:01:38 +00:00
8ba9ca5869 Remove qsort_func_t, belatedly. 2005-03-11 07:36:13 +00:00
Ron Koenderink
6fb90fb62c (newe): Remove wforce, not used anymore. 2005-03-10 22:25:58 +00:00
ed7adb7cf6 (loginit): Working directory is the data directory; simplify.
(loginit, logerror): Use plain char * instead of s_char *.
2005-03-10 19:33:12 +00:00
21088661d6 (emp_config): The previous rev. broke the documented feature that
missing default econfig means default configuration.  Fix.
2005-03-10 19:19:46 +00:00
7f000ce9cc Fix ugly line breaks. 2005-03-10 19:17:15 +00:00
a53c6e74c4 Update for recent pconfig changes. 2005-03-10 19:12:51 +00:00
5b57f4c222 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
2005-03-10 18:35:27 +00:00
Ron Koenderink
98f3d6efca (main,service_main) [_WIN32]: Change startup errors to stderr from
logerror() as log file is not open yet.
2005-03-10 18:00:40 +00:00
Ron Koenderink
f03de3f9a5 (service_main) [_WIN32]: Remove init_server() as it has already been done. 2005-03-10 16:15:30 +00:00
Ron Koenderink
b961414862 (main) [_WIN32]: Add extern file for chdir().
(main) [_WIN32]: Add #ifdef for tbuf as it is only used in LINUX and
EMPTH_POSIX.
2005-03-10 16:13:51 +00:00
d20fb6ba39 (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.
2005-03-09 19:37:48 +00:00
ba7d26b2ba (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.
2005-03-09 19:25:20 +00:00
fcf064625d (main): Non-zero flags imply !daemonize. Make explicit. 2005-03-09 18:57:53 +00:00
29da4b6cf4 (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.
2005-03-09 18:44:50 +00:00
1583d0c6a2 (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.
2005-03-09 17:11:58 +00:00
12518b82dd Fix missing include. 2005-03-09 16:56:39 +00:00
6309973d07 Fix typos, update paths that changed since this was written. 2005-03-09 16:46:45 +00:00
84b8189c13 (daemon, daemonize): Rename to avoid name clash with BSD's daemon().
(daemonize): Supply missing declaration.
2005-03-09 14:45:41 +00:00
30f2b2c4ea (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.
2005-03-08 16:51:19 +00:00
Ron Koenderink
0b172c6553 (NS_ALL) [_WIN32]: Change NS_EVERYTHING back to NS_ALL, #undef NS_ALL to prevent conflict with winsock2.h 2005-03-08 00:04:43 +00:00
Ron Koenderink
ab2bea5810 (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.
2005-03-06 20:58:48 +00:00
Ron Koenderink
46a11d0d93 (main) [_WIN32]: Move install_service() so the config_file
can be verified before installing.
2005-03-06 20:54:30 +00:00
Ron Koenderink
0ba025cb4b (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.
2005-03-06 20:08:52 +00:00
Ron Koenderink
d1d7028fc7 (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).
2005-03-06 19:53:14 +00:00
830c171dd2 (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.
2005-03-05 20:38:01 +00:00
e215af5ac5 (init_files): Exit unsuccessfully when a file can't be opened. 2005-03-03 19:54:25 +00:00
Ron Koenderink
85150431ed (delete_old_news,init_nreport): Add void for extern prototypes. 2005-03-03 00:23:49 +00:00
Ron Koenderink
3d3d6755aa (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.
2005-03-02 23:53:10 +00:00
Ron Koenderink
55e6aca9e0 (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.
2005-03-02 12:47:15 +00:00
d4af51c9e2 Fix the previous rev. 2005-03-01 18:49:12 +00:00
Ron Koenderink
826c14ef79 (write_file,allocate_memory): Convert to stdio. 2005-03-01 13:50:56 +00:00
Ron Koenderink
df7dc203c4 (turn): Change to stdio.
(turn): Always close the file after attempting to write.
Fixes bug where the file is not close when there is writing
error.
2005-02-28 23:21:05 +00:00
0aaf0084aa (as_extend, as_costcomp, gen_power, powcmp): Fix non-portable function
cast.
(qsort_func_t): Unused, remove.
2005-02-24 18:47:26 +00:00
b360d076d3 (ship_bomb): Clarify. Also gets rid of compiler warning. 2005-02-24 17:55:28 +00:00