* 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-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
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;
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;
#include <stdio.h>
#include <unistd.h>
+#include "sigproc.h"
+
#include "cygerrno.h"
#include "cygserver_msg.h"
#include "cygserver_sem.h"
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);
/*****************************************************************************/
-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),
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
* 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.
return NULL;
}
- entry = new class process (cygpid, winpid);
+ entry = new class process (cygpid, winpid, signal_arrived);
if (!entry->is_active ())
{
LeaveCriticalSection (&_cache_write_access);
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; }
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;
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 (); }
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);
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);