4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-02-22 00:38:06 +08:00

* exceptions.cc (set_process_mask): Set pending signals only when signals

become unmasked.
* sigproc.cc (pending_signals): Flip back to a global.
(wait_sig): Don't set pending signals when there is an armed semaphore or
signal is blocked.
* shared.cc (shared_info::initialize): Add a username parameter for user-mode
mounts.  Reorganize to try to avoid startup race.
(memory_init): Move some stuff into shared_info::initialize.
* shared_info.h (shared_info::initialize): Change declaration.
(CURR_SHARED_MAGIC): Update.
This commit is contained in:
Christopher Faylor 2003-09-03 14:15:55 +00:00
parent 73b2114815
commit 75119e9980
5 changed files with 64 additions and 38 deletions

View File

@ -1,3 +1,17 @@
2003-09-03 Christopher Faylor <cgf@redhat.com>
* exceptions.cc (set_process_mask): Set pending signals only when
signals become unmasked.
* sigproc.cc (pending_signals): Flip back to a global.
(wait_sig): Don't set pending signals when there is an armed semaphore
or signal is blocked.
* shared.cc (shared_info::initialize): Add a username parameter for
user-mode mounts. Reorganize to try to avoid startup race.
(memory_init): Move some stuff into shared_info::initialize.
* shared_info.h (shared_info::initialize): Change declaration.
(CURR_SHARED_MAGIC): Update.
2003-09-01 Christopher Faylor <cgf@redhat.com> 2003-09-01 Christopher Faylor <cgf@redhat.com>
* include/cygwin/version.h: Bump DLL minor number to 4. * include/cygwin/version.h: Bump DLL minor number to 4.

View File

@ -963,11 +963,15 @@ set_process_mask (sigset_t newmask)
sigproc_printf ("old mask = %x, new mask = %x", myself->getsigmask (), newmask); sigproc_printf ("old mask = %x, new mask = %x", myself->getsigmask (), newmask);
myself->setsigmask (newmask); // Set a new mask myself->setsigmask (newmask); // Set a new mask
mask_sync->release (); mask_sync->release ();
if (oldmask != newmask) if (!(oldmask & ~newmask))
sig_dispatch_pending ();
else
sigproc_printf ("not calling sig_dispatch_pending. sigtid %p current %p", sigproc_printf ("not calling sig_dispatch_pending. sigtid %p current %p",
sigtid, GetCurrentThreadId ()); sigtid, GetCurrentThreadId ());
else
{
extern bool pending_signals;
pending_signals = true;
sig_dispatch_pending ();
}
return; return;
} }

View File

@ -145,24 +145,40 @@ open_shared (const char *name, int n, HANDLE &shared_h, DWORD size, shared_locat
} }
void void
shared_info::initialize () shared_info::initialize (const char *user_name)
{ {
if (version) DWORD sversion = (DWORD) InterlockedExchange ((LONG *) &version, SHARED_VERSION_MAGIC);
if (!sversion)
{
/* Initialize the queue of deleted files. */
delqueue.init ();
/* Initialize tty table. */
tty.init ();
}
else
{ {
if (version != SHARED_VERSION_MAGIC) if (version != SHARED_VERSION_MAGIC)
multiple_cygwin_problem ("shared", version, SHARED_VERSION_MAGIC); {
else if (cb != SHARED_INFO_CB) multiple_cygwin_problem ("shared", version, SHARED_VERSION_MAGIC);
multiple_cygwin_problem ("shared size", cb, SHARED_INFO_CB); InterlockedExchange ((LONG *) &version, sversion);
return; }
while (!cb)
low_priority_sleep (0); // Should be hit only very very rarely
} }
/* Initialize the queue of deleted files. */ /* Initialize the Cygwin heap, if necessary */
delqueue.init (); if (!cygheap)
{
cygheap_init ();
cygheap->user.set_name (user_name);
}
heap_init ();
if (!sversion)
cb = sizeof (*this); // Do last, after all shared memory initializion
/* Initialize tty table. */
tty.init ();
version = SHARED_VERSION_MAGIC;
cb = sizeof (*this);
if (cb != SHARED_INFO_CB) if (cb != SHARED_INFO_CB)
system_printf ("size of shared memory region changed from %u to %u", system_printf ("size of shared memory region changed from %u to %u",
SHARED_INFO_CB, cb); SHARED_INFO_CB, cb);
@ -172,6 +188,13 @@ void __stdcall
memory_init () memory_init ()
{ {
getpagesize (); getpagesize ();
char user_name[UNLEN + 1];
DWORD user_name_len = UNLEN + 1;
if (!GetUserName (user_name, &user_name_len))
strcpy (user_name, "unknown");
/* Initialize general shared memory */ /* Initialize general shared memory */
HANDLE shared_h = cygheap ? cygheap->shared_h : NULL; HANDLE shared_h = cygheap ? cygheap->shared_h : NULL;
cygwin_shared = (shared_info *) open_shared ("shared", cygwin_shared = (shared_info *) open_shared ("shared",
@ -180,27 +203,12 @@ memory_init ()
sizeof (*cygwin_shared), sizeof (*cygwin_shared),
SH_CYGWIN_SHARED); SH_CYGWIN_SHARED);
cygwin_shared->initialize (); cygwin_shared->initialize (user_name);
/* Allocate memory for the per-user mount table */
char user_name[UNLEN + 1];
DWORD user_name_len = UNLEN + 1;
if (!GetUserName (user_name, &user_name_len))
strcpy (user_name, "unknown");
/* Initialize the Cygwin heap, if necessary */
if (!cygheap)
{
cygheap_init ();
cygheap->user.set_name (user_name);
}
cygheap->shared_h = shared_h; cygheap->shared_h = shared_h;
ProtectHandleINH (cygheap->shared_h); ProtectHandleINH (cygheap->shared_h);
heap_init (); /* Allocate memory for the per-user mount table */
mount_table = (mount_info *) open_shared (user_name, MOUNT_VERSION, mount_table = (mount_info *) open_shared (user_name, MOUNT_VERSION,
cygwin_mount_h, sizeof (mount_info), cygwin_mount_h, sizeof (mount_info),
SH_MOUNT_TABLE); SH_MOUNT_TABLE);

View File

@ -140,7 +140,7 @@ public:
#define SHARED_INFO_CB 47112 #define SHARED_INFO_CB 47112
#define CURR_SHARED_MAGIC 0x359218a2U #define CURR_SHARED_MAGIC 0x53f1a7f4U
/* NOTE: Do not make gratuitous changes to the names or organization of the /* NOTE: Do not make gratuitous changes to the names or organization of the
below class. The layout is checksummed to determine compatibility between below class. The layout is checksummed to determine compatibility between
@ -155,7 +155,7 @@ class shared_info
tty_list tty; tty_list tty;
delqueue_list delqueue; delqueue_list delqueue;
void initialize (); void initialize (const char *);
unsigned heap_chunk_size (); unsigned heap_chunk_size ();
}; };

View File

@ -147,7 +147,7 @@ muto NO_COPY *sync_proc_subproc = NULL; // Control access to subproc stuff
DWORD NO_COPY sigtid = 0; // ID of the signal thread DWORD NO_COPY sigtid = 0; // ID of the signal thread
static bool NO_COPY pending_signals = false; // true if signals pending bool NO_COPY pending_signals = false; // true if signals pending
/* Functions /* Functions
*/ */
@ -1190,7 +1190,7 @@ wait_sig (VOID *self)
{ {
/* If x > 0, we have to deal with a signal at some later point */ /* If x > 0, we have to deal with a signal at some later point */
if (rc != RC_NOSYNC && x > 0) if (rc != RC_NOSYNC && x > 0)
pending_signals = true; // There should be an armed semaphore, in this case /*pending_signals = true*/; // There should be an armed semaphore, in this case
if (sig > 0 && sig != SIGKILL && sig != SIGSTOP && if (sig > 0 && sig != SIGKILL && sig != SIGSTOP &&
(sigismember (&myself->getsigmask (), sig) || (sigismember (&myself->getsigmask (), sig) ||
@ -1199,7 +1199,7 @@ wait_sig (VOID *self)
{ {
sigproc_printf ("signal %d blocked", sig); sigproc_printf ("signal %d blocked", sig);
x = InterlockedIncrement (myself->getsigtodo (sig)); x = InterlockedIncrement (myself->getsigtodo (sig));
pending_signals = true; /* pending_signals = true;*/ // will be set by set_process_mask
} }
else else
{ {
@ -1229,9 +1229,9 @@ wait_sig (VOID *self)
sigproc_printf ("Got signal %d", sig); sigproc_printf ("Got signal %d", sig);
if (!sig_handle (sig)) if (!sig_handle (sig))
{ {
pending_signals = true;
saw_failed_interrupt = true; saw_failed_interrupt = true;
x = InterlockedIncrement (myself->getsigtodo (sig)); x = InterlockedIncrement (myself->getsigtodo (sig));
pending_signals = true;
} }
} }
if (rc == RC_NOSYNC && x > 0) if (rc == RC_NOSYNC && x > 0)