Commit graph

56 commits

Author SHA1 Message Date
Ron Koenderink
71b46e770b (struct loc_Thread, empth_sem_wait, empth_sem_signal) [WIN32]:
Remove the semaphore mutex and replace with hThreadMutex instead
2007-01-18 14:28:23 +00:00
Ron Koenderink
68662df96a (struct loc_RWLock_t): Rename struct loc_RWLock_t to struct loc_RWLock
as the struct loc_RWLock_t is not a typedef.  No functional changes.
2007-01-18 01:22:32 +00:00
Ron Koenderink
c4cf0231ee (struct loc_Sem_t): Rename struct loc_Sem_t to struct loc_Sem
as the struct loc_Sem_t is not a typedef.  No functional changes.
2007-01-18 01:18:19 +00:00
Ron Koenderink
d6efd51b09 (struct loc_Thread_t): Rename struct loc_Thread_t to struct loc_Thread
as the struct loc_Thread_t is not a typedef.  No functional changes.
2007-01-18 01:12:43 +00:00
Ron Koenderink
98250f2300 (empth_wait_for_signal) [WIN32]: Simplify empth_wait_for_signal()
by combined the waiting for hShutdownEvent and hThreadMutex
using the optional parmeter added to loc_RunThisThread().
2007-01-18 01:05:19 +00:00
Ron Koenderink
0c52f203c0 (struct loc_Thread_t, struct loc_Sem_t, hThreadStartEvent)
(loc_RunThisThread, empth_init, empth_create, empth_wait_for_signal)
[EMPTH_W32]: Remove some incorrect references to semaphones
in the comments.  No functional changes.
2007-01-15 13:34:33 +00:00
Ron Koenderink
71e0f98825 (loc_RunThread, empth_init, empth_threadMain, empth_yield)
(empth_select, empth_sleep, empth_wait_for_signal)
(empth_sem_wait) [EMPTH_W32]: Add the ability to wait additional
event in loc_RunThread() when acquiring the hThread mutex.

(empth_rwlock_t, empth_rwlock_create, empth_rwlock_destroy)
(empth_rwlock_wrlock, empth_rwlock_rdlock, empth_rwlock_unlock): New.

(empth_rwlock_t, empth_rwlock_create, empth_rwlock_destroy)
(empth_rwlock_wrlock, empth_rwlock_rdlock, empth_rwlock_unlock)
[EMPTH_W32]: WIN32 implementation.

(empth_rwlock_t, empth_rwlock_create, empth_rwlock_destroy)
(empth_rwlock_wrlock, empth_rwlock_rdlock, empth_rwlock_unlock)
(lwp_rwlock, lwp_rwlock_create, lwp_rwlock_destroy)
(lwp_rwlock_wrlock, lwp_rwlock_rdlock, lwp_rwlock_unlock)
[EMPTH_LWP]: LWP implementation.

(empth_rwlock_t, empth_rwlock_create, empth_rwlock_destroy)
(empth_rwlock_wrlock, empth_rwlock_rdlock, empth_rwlock_unlock)
[EMPTH_POSIX]: pthread implementation.
2007-01-15 12:45:35 +00:00
63bdc89835 Update copyright notice. 2007-01-09 19:09:31 +00:00
Ron Koenderink
897c212bfa Add missing prototypes.h to get logerror(). 2006-07-11 22:06:03 +00:00
e42053d928 Break inclusion cycle: prototypes.h and commands.h included each
other.  Ensure headers in include/ can be included in any order
(except for econfig-spec.h, which is special).  New header types.h to
help avoid inclusion cycles.  Sort include directives.  Remove some
superflous includes.
2006-07-10 06:37:23 +00:00
Ron Koenderink
0c53200e8e (empth_wait_for_signal) [_WIN32]: Add thread block for the main thread,
otherwise the main thread blocks all others.
2006-06-10 03:57:50 +00:00
1ca0b5cb2b Finally merge the journal patch:
(keep_journal): New econfig key.
(player_main): Log player login and logout.
(recvclient): Log player input.
(ef_open_srv, ef_close_srv): Log startup and shutdown.
(update_main): Log update.

Support the common SIGHUP log rotation idiom:
(empth_wait_for_shutdown, empth_wait_for_signal): Rename.
[EMPTH_LWP, EMPTH_POSIX] (empth_init, empth_wait_for_signal): Wait for
SIGHUP as well.
(main) [SIGHUP]: Reopen journal when empth_wait_for_signal() returns
SIGHUP.
2006-06-08 20:11:26 +00:00
7183516d91 (empth_init_signals): Don't catch SIGINT and SIGTERM.
(empth_wait_for_shutdown): New.
(main): Use it to wait for shutdown signal, then shut down.  Closes
#770492.
(empth_exit): Remove the weird special case for main thread.

Implement empth_wait_for_shutdown() for EMPTH_LWP:
[EMPTH_LWP] (lwpInitSigWait, lwpSigWait, lwpSigWakeup): New.
Declaration of lwpSigWait was accidentally committed in the previous
revision of lwp.h.
[EMPTH_LWP] (lwpInitSystem): New parameter waitset, pass it on to
lwpInitSigWait().
[EMPTH_LWP] (lwpReschedule): Call lwpSigWakeup().
[EMPTH_LWP] (empth_init): Declare signals needed by
empth_wait_for_shutdown().
(empth_wait_for_shutdown): Implement on top of lwpSigWait().

Implement empth_wait_for_shutdown() for EMPTH_POSIX:
[EMPTH_POSIX] (empth_init): Block signals, so that
empth_wait_for_shutdown() can use sigwait() safely.
(empth_wait_for_shutdown): Implement on top of sigwait().

Implement empth_wait_for_shutdown() for EMPTH_W32:
(empth_wait_for_shutdown): Implement on top of loc_BlockMainThread().
2006-06-07 21:01:16 +00:00
0b1f561e97 Comments, whitespace. 2006-06-02 05:49:29 +00:00
f3e85c2f70 Coding style, comments, spelling... 2006-05-26 18:46:50 +00:00
4c4fdca42b Line breaks and other formatting issues. No functional changes. 2006-05-21 13:05:24 +00:00
e28851b8e9 Normalize unsigned int to just unsigned. 2006-04-30 12:26:07 +00:00
ba11aaaa36 (empth_create): LWP yields, and it's the reference implementation.
Document and fix the others.
2006-03-25 07:49:37 +00:00
f5a9284867 Update known contributors comment. 2006-02-24 21:35:27 +00:00
4515b84c59 COPYING duplicates information from README. Remove. Move GPL from
LICENSE to COPYING, because that's where it usually is.  Update all
the references to these files.
2006-01-21 19:48:41 +00:00
3e400c018c Update copyright notice. 2006-01-05 13:36:57 +00:00
Ron Koenderink
025135bad0 (loc_RunThisThread, loc_BlockThisThread) [_WIN32]:
Add void to parameter declarations.

(empth_threadMain) [_WIN32]: Add static declaration for the function.

(empth_init) [_WIN32]: Change the format "lu" for GetLastError()
in logerror() calls.
2006-01-01 20:23:51 +00:00
Ron Koenderink
354af75dd6 (empth_threadMain) [_WIN32]: Add include file for time(). 2006-01-01 15:56:35 +00:00
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