* 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:
parent
2a566ac3ef
commit
373a036f7b
|
@ -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>
|
2004-01-16 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* process.h (cleanup_routine::~cleanup_routine): Make pure virtual
|
* process.h (cleanup_routine::~cleanup_routine): Make pure virtual
|
||||||
|
|
|
@ -188,9 +188,14 @@ _msleep (void *ident, struct mtx *mtx, int priority,
|
||||||
if (mtx)
|
if (mtx)
|
||||||
mtx_unlock (mtx);
|
mtx_unlock (mtx);
|
||||||
int old_priority = set_priority (priority);
|
int old_priority = set_priority (priority);
|
||||||
/* PCATCH can't be handled here. */
|
HANDLE obj[4] = { evt, td->client->handle (), msleep_glob_evt, td->client->signal_arrived () };
|
||||||
HANDLE obj[3] = { evt, td->client->handle (), msleep_glob_evt };
|
/* PCATCH handling. If PCATCH is given and signal_arrived is a valid
|
||||||
switch (WaitForMultipleObjects (3, obj, FALSE, timo ?: INFINITE))
|
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. */
|
case WAIT_OBJECT_0: /* wakeup() has been called. */
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
@ -201,6 +206,9 @@ _msleep (void *ident, struct mtx *mtx, int priority,
|
||||||
case WAIT_OBJECT_0 + 1: /* The dependent process has exited. */
|
case WAIT_OBJECT_0 + 1: /* The dependent process has exited. */
|
||||||
ret = EIDRM;
|
ret = EIDRM;
|
||||||
break;
|
break;
|
||||||
|
case WAIT_OBJECT_0 + 3: /* Signal for calling process arrived. */
|
||||||
|
ret = EINTR;
|
||||||
|
break;
|
||||||
case WAIT_TIMEOUT:
|
case WAIT_TIMEOUT:
|
||||||
ret = EWOULDBLOCK;
|
ret = EWOULDBLOCK;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -21,6 +21,8 @@ details. */
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "sigproc.h"
|
||||||
|
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "cygserver_msg.h"
|
#include "cygserver_msg.h"
|
||||||
#include "cygserver_sem.h"
|
#include "cygserver_sem.h"
|
||||||
|
|
|
@ -55,7 +55,8 @@ client_request_msg::serve (transport_layer_base *const conn,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
process *const client = cache->process (_parameters.in.ipcblk.cygpid,
|
process *const client = cache->process (_parameters.in.ipcblk.cygpid,
|
||||||
_parameters.in.ipcblk.winpid);
|
_parameters.in.ipcblk.winpid,
|
||||||
|
_parameters.in.ipcblk.signal_arrived);
|
||||||
if (!client)
|
if (!client)
|
||||||
{
|
{
|
||||||
error_code (EAGAIN);
|
error_code (EAGAIN);
|
||||||
|
|
|
@ -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),
|
: _cygpid (cygpid),
|
||||||
_winpid (winpid),
|
_winpid (winpid),
|
||||||
_hProcess (NULL),
|
_hProcess (NULL),
|
||||||
|
_signal_arrived (INVALID_HANDLE_VALUE),
|
||||||
_cleaning_up (false),
|
_cleaning_up (false),
|
||||||
_exit_status (STILL_ACTIVE),
|
_exit_status (STILL_ACTIVE),
|
||||||
_routines_head (NULL),
|
_routines_head (NULL),
|
||||||
|
@ -60,13 +61,22 @@ process::process (const pid_t cygpid, const DWORD winpid)
|
||||||
else
|
else
|
||||||
debug_printf ("got handle %p for new cache process %d(%lu)",
|
debug_printf ("got handle %p for new cache process %d(%lu)",
|
||||||
_hProcess, _cygpid, _winpid);
|
_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);
|
InitializeCriticalSection (&_access);
|
||||||
}
|
}
|
||||||
|
|
||||||
process::~process ()
|
process::~process ()
|
||||||
{
|
{
|
||||||
DeleteCriticalSection (&_access);
|
DeleteCriticalSection (&_access);
|
||||||
(void) CloseHandle (_hProcess);
|
CloseHandle (_signal_arrived);
|
||||||
|
CloseHandle (_hProcess);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No need to be thread-safe as this is only ever called by
|
/* 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.
|
* have been deleted once it has been unlocked.
|
||||||
*/
|
*/
|
||||||
class process *
|
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
|
/* TODO: make this more granular, so a search doesn't involve the
|
||||||
* write lock.
|
* write lock.
|
||||||
|
@ -243,7 +254,7 @@ process_cache::process (const pid_t cygpid, const DWORD winpid)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
entry = new class process (cygpid, winpid);
|
entry = new class process (cygpid, winpid, signal_arrived);
|
||||||
if (!entry->is_active ())
|
if (!entry->is_active ())
|
||||||
{
|
{
|
||||||
LeaveCriticalSection (&_cache_write_access);
|
LeaveCriticalSection (&_cache_write_access);
|
||||||
|
|
|
@ -71,12 +71,14 @@ class process
|
||||||
friend class process_cleanup;
|
friend class process_cleanup;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
process (pid_t cygpid, DWORD winpid);
|
process (pid_t cygpid, DWORD winpid,
|
||||||
|
HANDLE signal_arrived = INVALID_HANDLE_VALUE);
|
||||||
~process ();
|
~process ();
|
||||||
|
|
||||||
pid_t cygpid () const { return _cygpid; }
|
pid_t cygpid () const { return _cygpid; }
|
||||||
DWORD winpid () const { return _winpid; }
|
DWORD winpid () const { return _winpid; }
|
||||||
HANDLE handle () const { return _hProcess; }
|
HANDLE handle () const { return _hProcess; }
|
||||||
|
HANDLE signal_arrived () const { return _signal_arrived; }
|
||||||
|
|
||||||
bool is_active () const { return _exit_status == STILL_ACTIVE; }
|
bool is_active () const { return _exit_status == STILL_ACTIVE; }
|
||||||
|
|
||||||
|
@ -90,6 +92,7 @@ private:
|
||||||
const pid_t _cygpid;
|
const pid_t _cygpid;
|
||||||
const DWORD _winpid;
|
const DWORD _winpid;
|
||||||
HANDLE _hProcess;
|
HANDLE _hProcess;
|
||||||
|
HANDLE _signal_arrived;
|
||||||
long _cleaning_up;
|
long _cleaning_up;
|
||||||
DWORD _exit_status; // Set in the constructor and in exit_code ().
|
DWORD _exit_status; // Set in the constructor and in exit_code ().
|
||||||
cleanup_routine *_routines_head;
|
cleanup_routine *_routines_head;
|
||||||
|
@ -131,7 +134,8 @@ public:
|
||||||
process_cache (unsigned int initial_workers);
|
process_cache (unsigned int initial_workers);
|
||||||
~process_cache ();
|
~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 (); }
|
bool running () const { return _queue.running (); }
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,8 @@ client_request_sem::serve (transport_layer_base *const conn,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
process *const client = cache->process (_parameters.in.ipcblk.cygpid,
|
process *const client = cache->process (_parameters.in.ipcblk.cygpid,
|
||||||
_parameters.in.ipcblk.winpid);
|
_parameters.in.ipcblk.winpid,
|
||||||
|
_parameters.in.ipcblk.signal_arrived);
|
||||||
if (!client)
|
if (!client)
|
||||||
{
|
{
|
||||||
error_code (EAGAIN);
|
error_code (EAGAIN);
|
||||||
|
|
|
@ -55,7 +55,8 @@ client_request_shm::serve (transport_layer_base *const conn,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
process *const client = cache->process (_parameters.in.ipcblk.cygpid,
|
process *const client = cache->process (_parameters.in.ipcblk.cygpid,
|
||||||
_parameters.in.ipcblk.winpid);
|
_parameters.in.ipcblk.winpid,
|
||||||
|
_parameters.in.ipcblk.signal_arrived);
|
||||||
if (!client)
|
if (!client)
|
||||||
{
|
{
|
||||||
error_code (EAGAIN);
|
error_code (EAGAIN);
|
||||||
|
|
Loading…
Reference in New Issue