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:
authorChristopher Faylor <me@cgf.cx>2003-09-03 18:15:55 +0400
committerChristopher Faylor <me@cgf.cx>2003-09-03 18:15:55 +0400
commit75119e9980e160d8766111f40353df61abc8159b (patch)
treea4acdc580af9f88230cd8636a906637975e2d0c4 /winsup/cygwin/shared.cc
parent73b21148158daab0873ad40309c72b1f3de66fa5 (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/cygwin/shared.cc')
-rw-r--r--winsup/cygwin/shared.cc66
1 files changed, 37 insertions, 29 deletions
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);