Commit graph

33 commits

Author SHA1 Message Date
69150d10fc (EMPTH_LWP, EMPTH_POSIX, EMPTH_W32): Define in config.h instead of
compiler command line.  Don't bother to conditionalize code in .c
files that are only compiled when their thread package is used.

(_EMPTH_LWP, EMPTH_LWP, _EMPTH_POSIX, EMPTH_POSIX, _EMPTH_WIN32)
(EMPTH_W32): Identifiers beginning with an underscore and an uppercase
letter are reserved for any use.  Rename.
2005-12-28 14:27:15 +00:00
3aebb68ee7 Include config.h. 2005-12-27 18:04:19 +00:00
e6145fa515 (empth_start, empth_init) [_EMPTH_POSIX]: Do not handle SIGALRM. We
don't raise it, and the signal handler is fishy.
(empth_alarm): Unused, remove.
2005-10-26 16:30:00 +00:00
Ron Koenderink
4ea137e887 (empth_init) [_WIN32]: Change flags to global_flags to prevent
scope conflict with the parameter flags.
2005-07-02 14:06:10 +00:00
8e8ffb483c (loc_GVAR): Putting file local variables into a struct serves no
useful purpose whatsoever.  Peel off the struct.
2005-06-30 19:53:03 +00:00
b239d6e3b1 (loc_Thread, loc_Sem_t): Remove typedef, use the typedef name defined
in the header instead.

Remove some superflous casts.
2005-06-30 14:25:30 +00:00
Ron Koenderink
ec5a8b31ba (loc_Sem_t, empth_sem_t) [_WIN32]: empthread.h defines empth_sem_t as
incomplete type struct loc_Sem_t.  Instead of completing it here, the
code defined an unrelated type loc_Sem_t as (complete) type struct
empth_sem_t.  The resulting type errors were swept under the carpet
with casts.  Obvious fix.
2005-06-26 18:31:14 +00:00
Ron Koenderink
8d284c5b4a (empth_sleep) [_WIN32]: If the sleep returns early, go back to sleep.
Short sleeps can cause double-updates and other trouble.

[_WIN32] (loc_SleepThisThread): Not used, removed.
2005-06-25 16:49:20 +00:00
060df4ec8f Document Empire's thread abstraction. Minor cleanups:
(empth_init): Change first parameter to void **.
(empth_sleep): Change parameter to time_t.
2005-06-25 16:37:59 +00:00
8585ec930f Remove some redundant casts. 2005-06-12 08:17:13 +00:00
4f59fc9967 Remove a bunch of redundant casts. 2005-06-12 06:31:48 +00:00
Ron Koenderink
f826221a58 [_WIN32]: Add #define WIN32 whereever winsock2.h is used. There is bug
in the VC7 version of winsock2.h.  In version VC7, the #pragma
pack(push) and pack(pop) have an #ifdef !WIN32 add to them.  However,
if WIN32 is not defined at the beginning, the push is done but by the
time the pop is reach something else has set WIN32 define so the pop
is not done, and it changes the default pack from /Zp2 to /Zp4, which
makes the data structures incompatible between objects with winsock2.h
and without winsock2.h.  By adding the WIN32 both the push and pop are
not done.
2005-03-20 11:07:45 +00:00
345ad3dfe0 Update copyright notice. 2005-03-16 22:03:16 +00:00
9e08f17fd3 Fix comment line breaks. 2005-03-16 07:19:07 +00:00
Ron Koenderink
c38a64d3a9 (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.
2005-03-16 02:39:51 +00:00
Ron Koenderink
9227a314c5 (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.
2005-03-15 18:19:07 +00:00
Ron Koenderink
1bbd7e5342 (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.
2005-03-13 21:53:23 +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
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
84b8189c13 (daemon, daemonize): Rename to avoid name clash with BSD's daemon().
(daemonize): Supply missing declaration.
2005-03-09 14:45:41 +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
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
Ron Koenderink
aabed1b346 [_WIN32]: Upgrade to Windows Sockets 2. 2004-12-31 20:40:39 +00:00
Ron Koenderink
e342a73130 (main,close_files,loc_NT_Term,empth_exit):
Add Windows Service to the server.
This includes adding install service and remove service option.
Move the start code from main to separate function.
Make close_files() and loc_NT_Term() global.
Move disassoc() to be earlier in the startup sequence.
2004-12-21 03:10:30 +00:00
fac342ed49 Update copyright notice. 2004-09-07 15:07:16 +00:00
Ron Koenderink
1fcc9f68fd Added srand call to thread startup as each thread needs to be seeded in Windows. 2004-08-14 19:35:38 +00:00
8d438a4601 (loginit, main): Pass log file basename as parameter.
(logerror): Require prior call of loginit().
(empth_exit) [_EMPTH_WIN32]: Don't print the log file name here, it's
not modular.
(program, getlogfile): Unused, remove.
2004-02-19 21:15:16 +00:00
e446bfd904 (empth_t, empth_sem_t) [_EMPTH_WIN32]: Use incomplete types, not void for
abstract data types.
2004-02-17 18:05:23 +00:00
237baffca9 Supply prototypes where possible. This uncovered type errors with
thread entrypoints:
(lwpSelect, shutdown_sequence): Parameters didn't match thread entry
point prototype.
(lwpEntryPoint): Arguments didn't match thread entry point prototype.

Change linkage of functions without prototype declaration to static
where possible.

Remove some superflous declarations, replace others by suitable
includes.
2004-02-17 17:59:30 +00:00
4fa84b5cb1 (emp_sig_t): Pre-ISO C compatibility cruft. Just use void. 2004-02-15 21:00:27 +00:00
1504d1f13b (empth_exit): Fix shutdown on reading "quit" from stdin (crash bug,
reportedly).
2004-01-15 16:29:53 +00:00
9b7adfbecc Indented with src/scripts/indent-emp. 2003-09-02 20:48:48 +00:00
d8b7fdfae1 Import of Empire 4.2.12 2003-08-23 12:23:04 +00:00