summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/shared.cc
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2008-07-27 22:31:48 +0000
committerChristopher Faylor <me@cgf.cx>2008-07-27 22:31:48 +0000
commit038af33480450d3092adb520ce0974cb23efde9c (patch)
tree78c3033e59bb364c54f1a5790e4404e64a0baca4 /winsup/cygwin/shared.cc
parentb58e5f427a6905c1cefb2205c2359eef177dfb3a (diff)
downloadcygnal-038af33480450d3092adb520ce0974cb23efde9c.tar.gz
cygnal-038af33480450d3092adb520ce0974cb23efde9c.tar.bz2
cygnal-038af33480450d3092adb520ce0974cb23efde9c.zip
* dcrt0.cc (dll_crt0_0): Remove calling malloc_init and
user_shared_initialize_1 from here. (dll_crt0_1): Remove dynamically_loaded check. Just call malloc_init and user_shared_initialize unconditionally. * shared.cc (user_shared_create): Rename from user_shared_initialize. (user_shared_initialize): Rename from user_shared_initialize_1. Move complete user_shared content initialization code here from user_shared_create. * syscalls.cc (seteuid32): Remove call to user_shared_initialize_1. That is implied by the "true" argument to user_shared_create().
Diffstat (limited to 'winsup/cygwin/shared.cc')
-rw-r--r--winsup/cygwin/shared.cc43
1 files changed, 21 insertions, 22 deletions
diff --git a/winsup/cygwin/shared.cc b/winsup/cygwin/shared.cc
index 23a8d992d..5989dbd1a 100644
--- a/winsup/cygwin/shared.cc
+++ b/winsup/cygwin/shared.cc
@@ -198,12 +198,13 @@ open_shared (const char *name, int n, HANDLE& shared_h, DWORD size,
return shared;
}
-/* User shared initialization which requires malloc and cygtls stuff has to
- go here. */
+/* Second half of user shared initialization: Initialize content. */
void
-user_shared_initialize_1 ()
+user_shared_initialize ()
{
- if (!user_shared->cb)
+ DWORD sversion = (DWORD) InterlockedExchange ((LONG *) &user_shared->version, USER_VERSION_MAGIC);
+ /* Wait for initialization of the Cygwin per-user shared, if necessary */
+ if (!sversion)
{
cygpsid sid (cygheap->user.sid ());
struct passwd *pw = internal_getpwsid (sid);
@@ -214,10 +215,20 @@ user_shared_initialize_1 ()
user_shared->mountinfo.init (); /* Initialize the mount table. */
user_shared->cb = sizeof (*user_shared);
}
+ else
+ {
+ while (!user_shared->cb)
+ low_priority_sleep (0); // Should be hit only very very rarely
+ if (user_shared->version != sversion)
+ multiple_cygwin_problem ("user shared memory version", user_shared->version, sversion);
+ else if (user_shared->cb != sizeof (*user_shared))
+ multiple_cygwin_problem ("user shared memory size", user_shared->cb, sizeof (*user_shared));
+ }
}
+/* First half of user shared initialization: Create shared mem region. */
void
-user_shared_initialize (bool reinit)
+user_shared_create (bool reinit)
{
char name[UNLEN + 1] = ""; /* Large enough for SID */
@@ -240,18 +251,8 @@ user_shared_initialize (bool reinit)
debug_printf ("opening user shared for '%s' at %p", name, user_shared);
ProtectHandleINH (cygwin_user_h);
debug_printf ("user shared version %x", user_shared->version);
-
- DWORD sversion = (DWORD) InterlockedExchange ((LONG *) &user_shared->version, USER_VERSION_MAGIC);
- /* Wait for initialization of the Cygwin per-user shared, if necessary */
- if (sversion)
- {
- while (!user_shared->cb)
- low_priority_sleep (0); // Should be hit only very very rarely
- if (user_shared->version != sversion)
- multiple_cygwin_problem ("user shared memory version", user_shared->version, sversion);
- else if (user_shared->cb != sizeof (*user_shared))
- multiple_cygwin_problem ("user shared memory size", user_shared->cb, sizeof (*user_shared));
- }
+ if (reinit)
+ user_shared_initialize ();
}
void __stdcall
@@ -367,16 +368,14 @@ memory_init ()
}
/* Initialize general shared memory */
- shared_locations sh_cygwin_shared = SH_CYGWIN_SHARED;
+ shared_locations sh_cygwin_shared;
cygwin_shared = (shared_info *) open_shared ("shared",
CYGWIN_VERSION_SHARED_DATA,
cygwin_shared_h,
sizeof (*cygwin_shared),
- sh_cygwin_shared);
-
+ sh_cygwin_shared = SH_CYGWIN_SHARED);
cygwin_shared->initialize ();
-
- user_shared_initialize (false);
+ user_shared_create (false);
}
unsigned