From e8190d8fbf0071f1ad596ae2adb6826ddaf21d9c Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Tue, 9 Mar 2010 16:07:15 +0000 Subject: * shared.cc (inst_root_inited): Delete. * (shared_info::initialize): Reorganize. Move call to init_installation_root here under spinlock control. Move unneeded non-shared_info initialization out of this function. (memory_init): Remove call to init_installation_root. Call heap_init and get_session_parent_dir here. --- winsup/cygwin/ChangeLog | 9 +++++++++ winsup/cygwin/shared.cc | 40 ++++++++++++++++------------------------ 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 205e4d57a..1d5f86747 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,12 @@ +2010-03-09 Christopher Faylor + + * shared.cc (inst_root_inited): Delete. + * (shared_info::initialize): Reorganize. Move call to + init_installation_root here under spinlock control. Move unneeded + non-shared_info initialization out of this function. + (memory_init): Remove call to init_installation_root. Call heap_init + and get_session_parent_dir here. + 2010-03-04 Corinna Vinschen * syscalls.cc (nt_path_has_executable_suffix): Change storage class of diff --git a/winsup/cygwin/shared.cc b/winsup/cygwin/shared.cc index 47fc50ec5..53c3c1894 100644 --- a/winsup/cygwin/shared.cc +++ b/winsup/cygwin/shared.cc @@ -37,7 +37,6 @@ HANDLE NO_COPY cygwin_user_h; WCHAR installation_root[PATH_MAX] __attribute__((section (".cygwin_dll_common"), shared)); UNICODE_STRING installation_key __attribute__((section (".cygwin_dll_common"), shared)); WCHAR installation_key_buf[18] __attribute__((section (".cygwin_dll_common"), shared)); -static bool inst_root_inited; /* Use absolute path of cygwin1.dll to derive the Win32 dir which is our installation_root. Note that we can't handle Cygwin installation @@ -116,7 +115,6 @@ init_installation_root () installation_key.Buffer[0] = L'\0'; } - inst_root_inited = true; } /* This function returns a handle to the top-level directory in the global @@ -382,7 +380,20 @@ void shared_info::initialize () { DWORD sversion = (DWORD) InterlockedExchange ((LONG *) &version, SHARED_VERSION_MAGIC); - if (sversion) + if (!sversion) + { + /* Initialize installation root dir. This is put here just to piggyback on the + shared memory spinlock. The installation root does not live in shared_info + shared memory. */ + init_installation_root (); + init_obcaseinsensitive ();/* Initialize obcaseinsensitive. */ + tty.init (); /* Initialize tty table. */ + mt.initialize (); /* Initialize shared tape information. */ + debug_printf ("Installation root: <%W> key: <%S>", + installation_root, &installation_key); + cb = sizeof (*this); /* Do last, after all shared memory initialization */ + } + else { if (sversion != SHARED_VERSION_MAGIC) { @@ -393,17 +404,6 @@ shared_info::initialize () low_priority_sleep (0); // Should be hit only very very rarely } - heap_init (); - get_session_parent_dir (); /* Create session dir if first process. */ - - if (!sversion) - { - init_obcaseinsensitive ();/* Initialize obcaseinsensitive. */ - tty.init (); /* Initialize tty table. */ - mt.initialize (); /* Initialize shared tape information. */ - cb = sizeof (*this); /* Do last, after all shared memory initialization */ - } - if (cb != SHARED_INFO_CB) system_printf ("size of shared memory region changed from %u to %u", SHARED_INFO_CB, cb); @@ -421,10 +421,6 @@ memory_init (bool init_cygheap) cygheap->user.init (); } - /* Initialize installation root dir. */ - if (!installation_root[0]) - init_installation_root (); - /* Initialize general shared memory */ shared_locations sh_cygwin_shared; cygwin_shared = (shared_info *) open_shared (L"shared", @@ -432,13 +428,9 @@ memory_init (bool init_cygheap) cygwin_shared_h, sizeof (*cygwin_shared), sh_cygwin_shared = SH_CYGWIN_SHARED); - /* Defer debug output printing the installation root and installation key - up to this point. Debug output except for system_printf requires - the global shared memory to exist. */ - if (inst_root_inited) - debug_printf ("Installation root: <%W> key: <%S>", - installation_root, &installation_key); cygwin_shared->initialize (); + heap_init (); + get_session_parent_dir (); /* Create session dir if first process. */ user_shared_create (false); } -- cgit v1.2.3