* 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.
This commit is contained in:
Corinna Vinschen 2004-02-06 16:25:58 +00:00
parent 2a566ac3ef
commit 373a036f7b
8 changed files with 57 additions and 12 deletions

View File

@ -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

View File

@ -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;

View File

@ -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"

View File

@ -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);

View File

@ -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);

View File

@ -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 (); }

View File

@ -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);

View File

@ -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);