mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-02-18 23:12:15 +08:00
* bsd_helper.h: Throughout, convert "struct thread" to "class thread".
* bsd_mutex.cc (_msleep): Fetch signal_arrived handle from thread's ipcblk. * process.h (class process): Drop _signal_arrived and align methods. (process_cache::process): Drop signal_arrived parameter. * process.cc (process::process): Ditto. Drop related code. (process::~process): Drop closing signal_arrived handle. (process_cache::process): Drop signal_arrived parameter in call to process::process. (thread::dup_signal_arrived): New method duplicating thread's signal_arrived handle. (thread::close_signal_arrived): New method closing thread's signal_arrived handle. * msg.cc (client_request_msg::serve): Drop signal_arrived parameter from call to process_cache::process. Use thread constructor to initialize td. * sem.cc (client_request_sem::serve): Ditto. * shm.cc (client_request_shm::serve): Ditto.
This commit is contained in:
parent
c95ce02160
commit
8d8f40361f
@ -1,3 +1,23 @@
|
||||
2015-01-19 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* bsd_helper.h: Throughout, convert "struct thread" to "class thread".
|
||||
* bsd_mutex.cc (_msleep): Fetch signal_arrived handle from thread's
|
||||
ipcblk.
|
||||
* process.h (class process): Drop _signal_arrived and align methods.
|
||||
(process_cache::process): Drop signal_arrived parameter.
|
||||
* process.cc (process::process): Ditto. Drop related code.
|
||||
(process::~process): Drop closing signal_arrived handle.
|
||||
(process_cache::process): Drop signal_arrived parameter in call to
|
||||
process::process.
|
||||
(thread::dup_signal_arrived): New method duplicating thread's
|
||||
signal_arrived handle.
|
||||
(thread::close_signal_arrived): New method closing thread's
|
||||
signal_arrived handle.
|
||||
* msg.cc (client_request_msg::serve): Drop signal_arrived parameter from
|
||||
call to process_cache::process. Use thread constructor to initialize td.
|
||||
* sem.cc (client_request_sem::serve): Ditto.
|
||||
* shm.cc (client_request_shm::serve): Ditto.
|
||||
|
||||
2014-11-06 Florian Friesdorf <flo@chaoflow.net>
|
||||
|
||||
* cygserver-config: Add -N option to allow different service name.
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* bsd_helper.h: Helps integrating BSD kernel code
|
||||
|
||||
Copyright 2003, 2012 Red Hat, Inc.
|
||||
Copyright 2003, 2012, 2015 Red Hat, Inc.
|
||||
|
||||
This file is part of Cygwin.
|
||||
|
||||
@ -39,24 +39,24 @@ extern SECURITY_ATTRIBUTES sec_all_nih;
|
||||
|
||||
void securityinit (void);
|
||||
|
||||
int win_copyin (struct thread *, const void *, void *, size_t);
|
||||
int win_copyout (struct thread *, const void *, void *, size_t);
|
||||
int win_copyin (class thread *, const void *, void *, size_t);
|
||||
int win_copyout (class thread *, const void *, void *, size_t);
|
||||
#define copyin(a,b,c) win_copyin((td),(a),(b),(c))
|
||||
#define copyout(a,b,c) win_copyout((td),(a),(b),(c))
|
||||
|
||||
void *get_token_info (HANDLE, TOKEN_INFORMATION_CLASS);
|
||||
int ipcperm (struct thread *, struct ipc_perm *, unsigned int);
|
||||
int suser (struct thread *);
|
||||
int ipcperm (class thread *, struct ipc_perm *, unsigned int);
|
||||
int suser (class thread *);
|
||||
bool adjust_identity_info (struct proc *p);
|
||||
|
||||
struct vmspace *ipc_p_vmspace (struct proc *);
|
||||
int ipcexit_creat_hookthread(struct thread *);
|
||||
int ipcexit_creat_hookthread(class thread *);
|
||||
void ipcinit (void);
|
||||
int ipcunload (void);
|
||||
|
||||
vm_object_t _vm_pager_allocate (int, int);
|
||||
#define vm_pager_allocate(a,b,s,c,d) _vm_pager_allocate((s),(mode))
|
||||
vm_object_t vm_object_duplicate (struct thread *td, vm_object_t object);
|
||||
vm_object_t vm_object_duplicate (class thread *td, vm_object_t object);
|
||||
void vm_object_deallocate (vm_object_t object);
|
||||
|
||||
void tunable_param_init (const char *, bool);
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* bsd_mutex.cc
|
||||
|
||||
Copyright 2003, 2004, 2005, 2007, 2012, 2014 Red Hat Inc.
|
||||
Copyright 2003, 2004, 2005, 2007, 2012, 2014, 2015 Red Hat Inc.
|
||||
|
||||
This file is part of Cygwin.
|
||||
|
||||
@ -314,13 +314,12 @@ _msleep (void *ident, struct mtx *mtx, int priority,
|
||||
evt,
|
||||
msleep_glob_evt,
|
||||
td->client->handle (),
|
||||
td->client->signal_arrived ()
|
||||
td->ipcblk->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)
|
||||
if ((priority & PCATCH) && obj[3])
|
||||
obj_cnt = 4;
|
||||
switch (WaitForMultipleObjects (obj_cnt, obj, FALSE, timo ?: INFINITE))
|
||||
{
|
||||
|
@ -55,8 +55,7 @@ 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.signal_arrived);
|
||||
_parameters.in.ipcblk.winpid);
|
||||
if (!client)
|
||||
{
|
||||
error_code (EAGAIN);
|
||||
@ -82,7 +81,7 @@ client_request_msg::serve (transport_layer_base *const conn,
|
||||
conn->revert_to_self ();
|
||||
/* sysv_msg.cc takes care of itself. */
|
||||
client->release ();
|
||||
thread td = { client, &_parameters.in.ipcblk, {-1, -1} };
|
||||
thread td (client, &_parameters.in.ipcblk, true);
|
||||
int res;
|
||||
msgop_t msgop = _parameters.in.msgop; /* Get's overwritten otherwise. */
|
||||
switch (msgop)
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* process.cc
|
||||
|
||||
Copyright 2001, 2002, 2003, 2004, 2005, 2014 Red Hat Inc.
|
||||
Copyright 2001, 2002, 2003, 2004, 2005, 2014, 2015 Red Hat Inc.
|
||||
|
||||
Written by Robert Collins <rbtcollins@hotmail.com>
|
||||
|
||||
@ -20,6 +20,8 @@ details. */
|
||||
|
||||
#include "process.h"
|
||||
|
||||
#include "cygserver_ipc.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define elements(ARRAY) (sizeof (ARRAY) / sizeof (*ARRAY))
|
||||
@ -39,11 +41,10 @@ process_cleanup::process ()
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
process::process (const pid_t cygpid, const DWORD winpid, HANDLE signal_arrived)
|
||||
process::process (const pid_t cygpid, const DWORD winpid)
|
||||
: _cygpid (cygpid),
|
||||
_winpid (winpid),
|
||||
_hProcess (NULL),
|
||||
_signal_arrived (INVALID_HANDLE_VALUE),
|
||||
_cleaning_up (false),
|
||||
_exit_status (STILL_ACTIVE),
|
||||
_routines_head (NULL),
|
||||
@ -60,19 +61,6 @@ process::process (const pid_t cygpid, const DWORD winpid, HANDLE signal_arrived)
|
||||
else
|
||||
debug_printf ("got handle %p for new cache process %d(%u)",
|
||||
_hProcess, _cygpid, _winpid);
|
||||
if (!signal_arrived)
|
||||
debug_printf ("signal_arrived NULL for process %d(%u)", _cygpid, _winpid);
|
||||
else 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 (%u)",
|
||||
GetLastError ());
|
||||
_signal_arrived = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
}
|
||||
InitializeCriticalSection (&_access);
|
||||
debug ("initialized (%u)", _cygpid);
|
||||
}
|
||||
@ -81,8 +69,6 @@ process::~process ()
|
||||
{
|
||||
debug ("deleting (%u)", _cygpid);
|
||||
DeleteCriticalSection (&_access);
|
||||
if (_signal_arrived && _signal_arrived != INVALID_HANDLE_VALUE)
|
||||
CloseHandle (_signal_arrived);
|
||||
CloseHandle (_hProcess);
|
||||
}
|
||||
|
||||
@ -239,8 +225,7 @@ process_cache::~process_cache ()
|
||||
* have been deleted once it has been unlocked.
|
||||
*/
|
||||
class process *
|
||||
process_cache::process (const pid_t cygpid, const DWORD winpid,
|
||||
HANDLE signal_arrived)
|
||||
process_cache::process (const pid_t cygpid, const DWORD winpid)
|
||||
{
|
||||
/* TODO: make this more granular, so a search doesn't involve the
|
||||
* write lock.
|
||||
@ -260,7 +245,7 @@ process_cache::process (const pid_t cygpid, const DWORD winpid,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
entry = new class process (cygpid, winpid, signal_arrived);
|
||||
entry = new class process (cygpid, winpid);
|
||||
if (!entry->is_active ())
|
||||
{
|
||||
LeaveCriticalSection (&_cache_write_access);
|
||||
@ -495,5 +480,26 @@ process_cache::find (const DWORD winpid, class process **previous)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
thread::dup_signal_arrived ()
|
||||
{
|
||||
if (ipcblk && ipcblk->signal_arrived
|
||||
&& !DuplicateHandle (client->handle (), ipcblk->signal_arrived,
|
||||
GetCurrentProcess (), &ipcblk->signal_arrived,
|
||||
0, FALSE, DUPLICATE_SAME_ACCESS))
|
||||
{
|
||||
system_printf ("error duplicating thread's signal_arrived "
|
||||
"to server (%u)", GetLastError ());
|
||||
ipcblk->signal_arrived = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
thread::close_signal_arrived ()
|
||||
{
|
||||
if (ipcblk && ipcblk->signal_arrived)
|
||||
CloseHandle (ipcblk->signal_arrived);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
#endif /* __OUTSIDE_CYGWIN__ */
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* process.h
|
||||
|
||||
Copyright 2001, 2002, 2003, 2004, 2005, 2012 Red Hat Inc.
|
||||
Copyright 2001, 2002, 2003, 2004, 2005, 2012, 2015 Red Hat Inc.
|
||||
|
||||
Written by Robert Collins <rbtcollins@hotmail.com>
|
||||
|
||||
@ -74,14 +74,12 @@ class process
|
||||
friend class process_cleanup;
|
||||
|
||||
public:
|
||||
process (pid_t cygpid, DWORD winpid,
|
||||
HANDLE signal_arrived = INVALID_HANDLE_VALUE);
|
||||
process (pid_t cygpid, DWORD winpid);
|
||||
~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; }
|
||||
|
||||
@ -102,7 +100,6 @@ 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;
|
||||
@ -144,8 +141,7 @@ public:
|
||||
process_cache (const size_t max_procs, const unsigned int initial_workers);
|
||||
~process_cache ();
|
||||
|
||||
class process *process (pid_t cygpid, DWORD winpid,
|
||||
HANDLE signal_arrived = INVALID_HANDLE_VALUE);
|
||||
class process *process (pid_t cygpid, DWORD winpid);
|
||||
|
||||
bool running () const { return _queue.running (); }
|
||||
|
||||
|
@ -52,8 +52,7 @@ 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.signal_arrived);
|
||||
_parameters.in.ipcblk.winpid);
|
||||
if (!client)
|
||||
{
|
||||
error_code (EAGAIN);
|
||||
@ -79,7 +78,7 @@ client_request_sem::serve (transport_layer_base *const conn,
|
||||
conn->revert_to_self ();
|
||||
/* sysv_sem.cc takes care of itself. */
|
||||
client->release ();
|
||||
thread td = { client, &_parameters.in.ipcblk, {-1, -1} };
|
||||
thread td (client, &_parameters.in.ipcblk, true);
|
||||
int res;
|
||||
switch (_parameters.in.semop)
|
||||
{
|
||||
|
@ -55,8 +55,7 @@ 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.signal_arrived);
|
||||
_parameters.in.ipcblk.winpid);
|
||||
if (!client)
|
||||
{
|
||||
error_code (EAGAIN);
|
||||
@ -82,7 +81,7 @@ client_request_shm::serve (transport_layer_base *const conn,
|
||||
conn->revert_to_self ();
|
||||
/* sysv_shm.cc takes care of itself. */
|
||||
client->release ();
|
||||
thread td = { client, &_parameters.in.ipcblk, {0, 0} };
|
||||
thread td (client, &_parameters.in.ipcblk, false);
|
||||
int res;
|
||||
shmop_t shmop = _parameters.in.shmop; /* Get's overwritten otherwise. */
|
||||
switch (shmop)
|
||||
|
Loading…
x
Reference in New Issue
Block a user