diff options
author | Christopher Faylor <me@cgf.cx> | 2003-09-03 18:15:55 +0400 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2003-09-03 18:15:55 +0400 |
commit | 75119e9980e160d8766111f40353df61abc8159b (patch) | |
tree | a4acdc580af9f88230cd8636a906637975e2d0c4 /winsup | |
parent | 73b21148158daab0873ad40309c72b1f3de66fa5 (diff) |
* 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.
Diffstat (limited to 'winsup')
-rw-r--r-- | winsup/cygwin/ChangeLog | 14 | ||||
-rw-r--r-- | winsup/cygwin/exceptions.cc | 10 | ||||
-rw-r--r-- | winsup/cygwin/shared.cc | 66 | ||||
-rw-r--r-- | winsup/cygwin/shared_info.h | 4 | ||||
-rw-r--r-- | winsup/cygwin/sigproc.cc | 8 |
5 files changed, 64 insertions, 38 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index a1e865051..8346715a7 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -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> * include/cygwin/version.h: Bump DLL minor number to 4. diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index c63ed2058..feffcd3d2 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -963,11 +963,15 @@ set_process_mask (sigset_t newmask) sigproc_printf ("old mask = %x, new mask = %x", myself->getsigmask (), newmask); myself->setsigmask (newmask); // Set a new mask mask_sync->release (); - if (oldmask != newmask) - sig_dispatch_pending (); - else + if (!(oldmask & ~newmask)) sigproc_printf ("not calling sig_dispatch_pending. sigtid %p current %p", sigtid, GetCurrentThreadId ()); + else + { + extern bool pending_signals; + pending_signals = true; + sig_dispatch_pending (); + } return; } diff --git a/winsup/cygwin/shared.cc b/winsup/cygwin/shared.cc index 8bcf2b7db..654ac572b 100644 --- a/winsup/cygwin/shared.cc +++ b/winsup/cygwin/shared.cc @@ -145,24 +145,40 @@ open_shared (const char *name, int n, HANDLE &shared_h, DWORD size, shared_locat } 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) - multiple_cygwin_problem ("shared", version, SHARED_VERSION_MAGIC); - else if (cb != SHARED_INFO_CB) - multiple_cygwin_problem ("shared size", cb, SHARED_INFO_CB); - return; + { + multiple_cygwin_problem ("shared", version, SHARED_VERSION_MAGIC); + InterlockedExchange ((LONG *) &version, sversion); + } + while (!cb) + low_priority_sleep (0); // Should be hit only very very rarely + } + + /* Initialize the Cygwin heap, if necessary */ + if (!cygheap) + { + cygheap_init (); + cygheap->user.set_name (user_name); } - /* Initialize the queue of deleted files. */ - delqueue.init (); + 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) system_printf ("size of shared memory region changed from %u to %u", SHARED_INFO_CB, cb); @@ -172,6 +188,13 @@ void __stdcall memory_init () { 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 */ HANDLE shared_h = cygheap ? cygheap->shared_h : NULL; cygwin_shared = (shared_info *) open_shared ("shared", @@ -180,27 +203,12 @@ memory_init () sizeof (*cygwin_shared), SH_CYGWIN_SHARED); - cygwin_shared->initialize (); - - /* 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); - } + cygwin_shared->initialize (user_name); cygheap->shared_h = 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, cygwin_mount_h, sizeof (mount_info), SH_MOUNT_TABLE); diff --git a/winsup/cygwin/shared_info.h b/winsup/cygwin/shared_info.h index c1ab3d58d..d73d0b078 100644 --- a/winsup/cygwin/shared_info.h +++ b/winsup/cygwin/shared_info.h @@ -140,7 +140,7 @@ public: #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 below class. The layout is checksummed to determine compatibility between @@ -155,7 +155,7 @@ class shared_info tty_list tty; delqueue_list delqueue; - void initialize (); + void initialize (const char *); unsigned heap_chunk_size (); }; diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index b14fbac1b..383de21a9 100644 --- a/winsup/cygwin/sigproc.cc +++ b/winsup/cygwin/sigproc.cc @@ -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 -static bool NO_COPY pending_signals = false; // true if signals pending +bool NO_COPY pending_signals = false; // true if signals pending /* Functions */ @@ -1190,7 +1190,7 @@ wait_sig (VOID *self) { /* If x > 0, we have to deal with a signal at some later point */ 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 && (sigismember (&myself->getsigmask (), sig) || @@ -1199,7 +1199,7 @@ wait_sig (VOID *self) { sigproc_printf ("signal %d blocked", sig); x = InterlockedIncrement (myself->getsigtodo (sig)); - pending_signals = true; + /* pending_signals = true;*/ // will be set by set_process_mask } else { @@ -1229,9 +1229,9 @@ wait_sig (VOID *self) sigproc_printf ("Got signal %d", sig); if (!sig_handle (sig)) { + pending_signals = true; saw_failed_interrupt = true; x = InterlockedIncrement (myself->getsigtodo (sig)); - pending_signals = true; } } if (rc == RC_NOSYNC && x > 0) |