mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-18 20:39:33 +08:00
* 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().
This commit is contained in:
parent
b58e5f427a
commit
038af33480
@ -1,3 +1,17 @@
|
||||
2008-07-27 Corinna Vinschen <corinna@vinschen.de>
|
||||
Christopher Faylor <me+cygwin@cgf.cx>
|
||||
|
||||
* 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().
|
||||
|
||||
2008-07-27 Christopher Faylor <me+cygwin@cgf.cx>
|
||||
|
||||
* mount.cc (mount_info::init): Add location where we're looking for
|
||||
|
@ -752,20 +752,6 @@ dll_crt0_0 ()
|
||||
events_init ();
|
||||
tty_list::init_session ();
|
||||
|
||||
if (dynamically_loaded)
|
||||
{
|
||||
/* When dynamically loaded. we must initialize the user shared memory
|
||||
entirely here since dll_crt0_1 will not be called. Stuff in
|
||||
user_shared_initialize_1 relies on malloc and cygtls being available
|
||||
and the initialization isn't finished without calling it. In the
|
||||
non-dynamical case this is called in dll_crt0_1, because malloc_init
|
||||
has to test for overloaded malloc functionality in the application.
|
||||
That's not an issue when cygwin is loaded dynamically. It will just
|
||||
use its own malloc area. */
|
||||
malloc_init ();
|
||||
user_shared_initialize_1 ();
|
||||
}
|
||||
|
||||
debug_printf ("finished dll_crt0_0 initialization");
|
||||
}
|
||||
|
||||
@ -778,11 +764,12 @@ dll_crt0_1 (void *)
|
||||
{
|
||||
check_sanity_and_sync (user_data);
|
||||
|
||||
if (!dynamically_loaded)
|
||||
{
|
||||
malloc_init ();
|
||||
user_shared_initialize_1 ();
|
||||
}
|
||||
/* Initialize malloc and then call user_shared_initialize since it relies
|
||||
on a functioning malloc and it's possible that the user's program may
|
||||
have overridden malloc. We only know about that at this stage,
|
||||
unfortunately. */
|
||||
malloc_init ();
|
||||
user_shared_initialize ();
|
||||
|
||||
#ifdef CGF
|
||||
int i = 0;
|
||||
|
@ -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
|
||||
|
@ -163,6 +163,7 @@ enum shared_locations
|
||||
SH_JUSTOPEN
|
||||
|
||||
};
|
||||
|
||||
void __stdcall memory_init ();
|
||||
void __stdcall shared_destroy ();
|
||||
|
||||
@ -185,6 +186,6 @@ char *__stdcall shared_name (char *, const char *, int);
|
||||
void *__stdcall open_shared (const char *name, int n, HANDLE &shared_h, DWORD size,
|
||||
shared_locations&, PSECURITY_ATTRIBUTES psa = &sec_all,
|
||||
DWORD access = FILE_MAP_READ | FILE_MAP_WRITE);
|
||||
extern void user_shared_initialize (bool reinit);
|
||||
extern void user_shared_initialize_1 ();
|
||||
extern void user_shared_create (bool reinit);
|
||||
extern void user_shared_initialize ();
|
||||
|
||||
|
@ -2612,10 +2612,8 @@ seteuid32 (__uid32_t uid)
|
||||
myself->uid = uid;
|
||||
groups.ischanged = FALSE;
|
||||
if (!issamesid)
|
||||
{
|
||||
user_shared_initialize (true);
|
||||
user_shared_initialize_1 ();
|
||||
}
|
||||
/* Recreate and fill out the user shared region for a new user. */
|
||||
user_shared_create (true);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user