This is the mail archive of the cygwin-cvs@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[newlib-cygwin] fork: Don't copy _main_tls->local_clib from *_impure_ptr


https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=48755fb9bca8ae379a6f96619b8b7774ff4b4494

commit 48755fb9bca8ae379a6f96619b8b7774ff4b4494
Author: Corinna Vinschen <corinna@vinschen.de>
Date:   Fri Mar 10 20:44:53 2017 +0100

    fork: Don't copy _main_tls->local_clib from *_impure_ptr
    
    So far we copy *_impure_ptr into _main_tls->local_clib if the child
    process has been forked from a pthread.  But that's not required.
    The local_clib area of the new thread is on the stack and the stack
    gets copied from the parent anyway (in frok::parent).  So we only
    have to make sure _main_tls is pointing to the right address and
    do the simple post-fork thread init.
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/fork.cc | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc
index ef5a268..73a72f5 100644
--- a/winsup/cygwin/fork.cc
+++ b/winsup/cygwin/fork.cc
@@ -143,15 +143,11 @@ frok::child (volatile char * volatile here)
 		myself->pid, myself->ppid, __builtin_frame_address (0));
   sigproc_printf ("hParent %p, load_dlls %d", hParent, load_dlls);
 
-  /* If we've played with the stack, stacksize != 0.  That means that
-     fork() was invoked from other than the main thread.  Make sure that
-     the threadinfo information is properly set up.  */
-  if (!fork_info->from_main)
+  /* Make sure threadinfo information is properly set up. */
+  if (&_my_tls != _main_tls)
     {
       _main_tls = &_my_tls;
       _main_tls->init_thread (NULL, NULL);
-      _main_tls->local_clib = *_impure_ptr;
-      _impure_ptr = &_main_tls->local_clib;
     }
 
   set_cygwin_privileges (hProcToken);
@@ -300,7 +296,6 @@ frok::parent (volatile char * volatile stack_here)
 
   ch.forker_finished = forker_finished;
 
-  ch.from_main = &_my_tls == _main_tls;
   ch.stackbase = NtCurrentTeb ()->Tib.StackBase;
   ch.stackaddr = NtCurrentTeb ()->DeallocationStack;
   if (!ch.stackaddr)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]