Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2015-01-19 20:42:38 +0300
committerCorinna Vinschen <corinna@vinschen.de>2015-01-19 20:42:38 +0300
commit8d8f40361f1d0e135f6679a00b19a0e1808df085 (patch)
tree49b3d6b790156e9c3ba6fd0e634940ddc6eb27d7 /winsup/cygserver
parentc95ce0216000cb8fb85d666adc79ed62b126d2ec (diff)
* 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.
Diffstat (limited to 'winsup/cygserver')
-rw-r--r--winsup/cygserver/ChangeLog20
-rw-r--r--winsup/cygserver/bsd_helper.h14
-rw-r--r--winsup/cygserver/bsd_mutex.cc7
-rw-r--r--winsup/cygserver/msg.cc5
-rw-r--r--winsup/cygserver/process.cc48
-rw-r--r--winsup/cygserver/process.h10
-rw-r--r--winsup/cygserver/sem.cc5
-rw-r--r--winsup/cygserver/shm.cc5
8 files changed, 66 insertions, 48 deletions
diff --git a/winsup/cygserver/ChangeLog b/winsup/cygserver/ChangeLog
index 0b08894d2..69685cd4b 100644
--- a/winsup/cygserver/ChangeLog
+++ b/winsup/cygserver/ChangeLog
@@ -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.
diff --git a/winsup/cygserver/bsd_helper.h b/winsup/cygserver/bsd_helper.h
index bc8d22810..acf5e83d9 100644
--- a/winsup/cygserver/bsd_helper.h
+++ b/winsup/cygserver/bsd_helper.h
@@ -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);
diff --git a/winsup/cygserver/bsd_mutex.cc b/winsup/cygserver/bsd_mutex.cc
index 66c4b2398..aadb479b6 100644
--- a/winsup/cygserver/bsd_mutex.cc
+++ b/winsup/cygserver/bsd_mutex.cc
@@ -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))
{
diff --git a/winsup/cygserver/msg.cc b/winsup/cygserver/msg.cc
index c92e698b0..ab3610e7a 100644
--- a/winsup/cygserver/msg.cc
+++ b/winsup/cygserver/msg.cc
@@ -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)
diff --git a/winsup/cygserver/process.cc b/winsup/cygserver/process.cc
index 12989a8d4..d78ca3715 100644
--- a/winsup/cygserver/process.cc
+++ b/winsup/cygserver/process.cc
@@ -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__ */
diff --git a/winsup/cygserver/process.h b/winsup/cygserver/process.h
index 3de11b6f8..507bbf0e9 100644
--- a/winsup/cygserver/process.h
+++ b/winsup/cygserver/process.h
@@ -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 (); }
diff --git a/winsup/cygserver/sem.cc b/winsup/cygserver/sem.cc
index 55cd6e51e..b0252a667 100644
--- a/winsup/cygserver/sem.cc
+++ b/winsup/cygserver/sem.cc
@@ -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)
{
diff --git a/winsup/cygserver/shm.cc b/winsup/cygserver/shm.cc
index 3be0d15f4..0d4af217a 100644
--- a/winsup/cygserver/shm.cc
+++ b/winsup/cygserver/shm.cc
@@ -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)