diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2004-02-06 16:25:58 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2004-02-06 16:25:58 +0000 |
commit | 373a036f7bcdc9ef29f340752024c976b1695d34 (patch) | |
tree | 7fb89276c893d104046bfdb65005ae24a23d3c7d /winsup/cygserver | |
parent | 2a566ac3ef08f056895433468390c116e22a5589 (diff) | |
download | newlib-373a036f7bcdc9ef29f340752024c976b1695d34.zip newlib-373a036f7bcdc9ef29f340752024c976b1695d34.tar.gz newlib-373a036f7bcdc9ef29f340752024c976b1695d34.tar.bz2 |
* bsd_mutex.cc (_msleep): Handle PCATCH using signal_arrived event.
* client.cc: Include sigproc.h.
* msg.cc (client_request_msg::serve): Accomodate third parameter to
process::process.
* sem.cc (client_request_sem::serve): Ditto.
* shm.cc (client_request_shm::serve): Ditto.
* process.cc (process::process): Duplicate signal_arrived into
Cygserver process space.
(process::~process): Close _signal_arrived handle.
(process_cache::process): Add signal_arrived handling.
* process.h (process::process): Add signal_arrived parameter.
(process:signal_arrived): New read accessor.
(process:_signal_arrived): New member.
(process_cache::process): Add signal_arrived parameter.
Diffstat (limited to 'winsup/cygserver')
-rw-r--r-- | winsup/cygserver/ChangeLog | 17 | ||||
-rw-r--r-- | winsup/cygserver/bsd_mutex.cc | 14 | ||||
-rw-r--r-- | winsup/cygserver/client.cc | 2 | ||||
-rw-r--r-- | winsup/cygserver/msg.cc | 3 | ||||
-rw-r--r-- | winsup/cygserver/process.cc | 19 | ||||
-rw-r--r-- | winsup/cygserver/process.h | 8 | ||||
-rw-r--r-- | winsup/cygserver/sem.cc | 3 | ||||
-rw-r--r-- | winsup/cygserver/shm.cc | 3 |
8 files changed, 57 insertions, 12 deletions
diff --git a/winsup/cygserver/ChangeLog b/winsup/cygserver/ChangeLog index e713ae1..838eee8 100644 --- a/winsup/cygserver/ChangeLog +++ b/winsup/cygserver/ChangeLog @@ -1,3 +1,20 @@ +2004-02-06 Corinna Vinschen <corinna@vinschen.de> + + * bsd_mutex.cc (_msleep): Handle PCATCH using signal_arrived event. + * client.cc: Include sigproc.h. + * msg.cc (client_request_msg::serve): Accomodate third parameter to + process::process. + * sem.cc (client_request_sem::serve): Ditto. + * shm.cc (client_request_shm::serve): Ditto. + * process.cc (process::process): Duplicate signal_arrived into + Cygserver process space. + (process::~process): Close _signal_arrived handle. + (process_cache::process): Add signal_arrived handling. + * process.h (process::process): Add signal_arrived parameter. + (process:signal_arrived): New read accessor. + (process:_signal_arrived): New member. + (process_cache::process): Add signal_arrived parameter. + 2004-01-16 Corinna Vinschen <corinna@vinschen.de> * process.h (cleanup_routine::~cleanup_routine): Make pure virtual diff --git a/winsup/cygserver/bsd_mutex.cc b/winsup/cygserver/bsd_mutex.cc index 9c7485b..af23f56 100644 --- a/winsup/cygserver/bsd_mutex.cc +++ b/winsup/cygserver/bsd_mutex.cc @@ -188,9 +188,14 @@ _msleep (void *ident, struct mtx *mtx, int priority, if (mtx) mtx_unlock (mtx); int old_priority = set_priority (priority); - /* PCATCH can't be handled here. */ - HANDLE obj[3] = { evt, td->client->handle (), msleep_glob_evt }; - switch (WaitForMultipleObjects (3, obj, FALSE, timo ?: INFINITE)) + HANDLE obj[4] = { evt, td->client->handle (), msleep_glob_evt, td->client->signal_arrived () }; + /* PCATCH handling. If PCATCH is given and signal_arrived is a valid + handle, then it's used in the WaitFor call and EINTR is returned. */ + int obj_cnt = 3; + if ((priority & PCATCH) + && td->client->signal_arrived () != INVALID_HANDLE_VALUE) + obj_cnt = 4; + switch (WaitForMultipleObjects (obj_cnt, obj, FALSE, timo ?: INFINITE)) { case WAIT_OBJECT_0: /* wakeup() has been called. */ ret = 0; @@ -201,6 +206,9 @@ _msleep (void *ident, struct mtx *mtx, int priority, case WAIT_OBJECT_0 + 1: /* The dependent process has exited. */ ret = EIDRM; break; + case WAIT_OBJECT_0 + 3: /* Signal for calling process arrived. */ + ret = EINTR; + break; case WAIT_TIMEOUT: ret = EWOULDBLOCK; break; diff --git a/winsup/cygserver/client.cc b/winsup/cygserver/client.cc index d8f7ac5..46451a9 100644 --- a/winsup/cygserver/client.cc +++ b/winsup/cygserver/client.cc @@ -21,6 +21,8 @@ details. */ #include <stdio.h> #include <unistd.h> +#include "sigproc.h" + #include "cygerrno.h" #include "cygserver_msg.h" #include "cygserver_sem.h" diff --git a/winsup/cygserver/msg.cc b/winsup/cygserver/msg.cc index 52fdcd0..fd5eaf5 100644 --- a/winsup/cygserver/msg.cc +++ b/winsup/cygserver/msg.cc @@ -55,7 +55,8 @@ client_request_msg::serve (transport_layer_base *const conn, return; } process *const client = cache->process (_parameters.in.ipcblk.cygpid, - _parameters.in.ipcblk.winpid); + _parameters.in.ipcblk.winpid, + _parameters.in.ipcblk.signal_arrived); if (!client) { error_code (EAGAIN); diff --git a/winsup/cygserver/process.cc b/winsup/cygserver/process.cc index 1cad238..8f1ff57 100644 --- a/winsup/cygserver/process.cc +++ b/winsup/cygserver/process.cc @@ -40,10 +40,11 @@ process_cleanup::process () /*****************************************************************************/ -process::process (const pid_t cygpid, const DWORD winpid) +process::process (const pid_t cygpid, const DWORD winpid, HANDLE signal_arrived) : _cygpid (cygpid), _winpid (winpid), _hProcess (NULL), + _signal_arrived (INVALID_HANDLE_VALUE), _cleaning_up (false), _exit_status (STILL_ACTIVE), _routines_head (NULL), @@ -60,13 +61,22 @@ process::process (const pid_t cygpid, const DWORD winpid) else debug_printf ("got handle %p for new cache process %d(%lu)", _hProcess, _cygpid, _winpid); + if (signal_arrived != INVALID_HANDLE_VALUE) + { + if (!DuplicateHandle (_hProcess, signal_arrived, + GetCurrentProcess (), &_signal_arrived, + 0, FALSE, DUPLICATE_SAME_ACCESS)) + system_printf ("error getting signal_arrived to server (%lu)", + GetLastError ()); + } InitializeCriticalSection (&_access); } process::~process () { DeleteCriticalSection (&_access); - (void) CloseHandle (_hProcess); + CloseHandle (_signal_arrived); + CloseHandle (_hProcess); } /* No need to be thread-safe as this is only ever called by @@ -221,7 +231,8 @@ process_cache::~process_cache () * have been deleted once it has been unlocked. */ class process * -process_cache::process (const pid_t cygpid, const DWORD winpid) +process_cache::process (const pid_t cygpid, const DWORD winpid, + HANDLE signal_arrived) { /* TODO: make this more granular, so a search doesn't involve the * write lock. @@ -243,7 +254,7 @@ process_cache::process (const pid_t cygpid, const DWORD winpid) return NULL; } - entry = new class process (cygpid, winpid); + entry = new class process (cygpid, winpid, signal_arrived); if (!entry->is_active ()) { LeaveCriticalSection (&_cache_write_access); diff --git a/winsup/cygserver/process.h b/winsup/cygserver/process.h index c062ee1..90d7c94 100644 --- a/winsup/cygserver/process.h +++ b/winsup/cygserver/process.h @@ -71,12 +71,14 @@ class process friend class process_cleanup; public: - process (pid_t cygpid, DWORD winpid); + process (pid_t cygpid, DWORD winpid, + HANDLE signal_arrived = INVALID_HANDLE_VALUE); ~process (); pid_t cygpid () const { return _cygpid; } DWORD winpid () const { return _winpid; } HANDLE handle () const { return _hProcess; } + HANDLE signal_arrived () const { return _signal_arrived; } bool is_active () const { return _exit_status == STILL_ACTIVE; } @@ -90,6 +92,7 @@ private: const pid_t _cygpid; const DWORD _winpid; HANDLE _hProcess; + HANDLE _signal_arrived; long _cleaning_up; DWORD _exit_status; // Set in the constructor and in exit_code (). cleanup_routine *_routines_head; @@ -131,7 +134,8 @@ public: process_cache (unsigned int initial_workers); ~process_cache (); - class process *process (pid_t cygpid, DWORD winpid); + class process *process (pid_t cygpid, DWORD winpid, + HANDLE signal_arrived = INVALID_HANDLE_VALUE); bool running () const { return _queue.running (); } diff --git a/winsup/cygserver/sem.cc b/winsup/cygserver/sem.cc index dd48123..82ad3de 100644 --- a/winsup/cygserver/sem.cc +++ b/winsup/cygserver/sem.cc @@ -52,7 +52,8 @@ client_request_sem::serve (transport_layer_base *const conn, return; } process *const client = cache->process (_parameters.in.ipcblk.cygpid, - _parameters.in.ipcblk.winpid); + _parameters.in.ipcblk.winpid, + _parameters.in.ipcblk.signal_arrived); if (!client) { error_code (EAGAIN); diff --git a/winsup/cygserver/shm.cc b/winsup/cygserver/shm.cc index d8284cd..48aec8a 100644 --- a/winsup/cygserver/shm.cc +++ b/winsup/cygserver/shm.cc @@ -55,7 +55,8 @@ client_request_shm::serve (transport_layer_base *const conn, return; } process *const client = cache->process (_parameters.in.ipcblk.cygpid, - _parameters.in.ipcblk.winpid); + _parameters.in.ipcblk.winpid, + _parameters.in.ipcblk.signal_arrived); if (!client) { error_code (EAGAIN); |