From 7aefc1596dd41465005dc9d7569a0ff6caa4a118 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Wed, 30 Apr 2008 09:51:38 +0000 Subject: [PATCH] * dtable.cc (dtable::release): Drop fixup_before handling. (dtable::fixup_before_fork): Remove. (dtable::fixup_before_exec): Remove. * dtable.h (class dtable): Remove cnt_need_fixup_before member. (dtable::dtable): Accommodate above change. (dtable::dec_need_fixup_before): Remove. (dtable::inc_need_fixup_before): Remove. (dtable::need_fixup_before): Remove. (dtable::fixup_before_exec): Remove declaration. (dtable::fixup_before_fork): Ditto. * fhandler.h (fhandler_base::fixup_before_fork_exec): Remove. (fhandler_base::need_fixup_before): Remove. * fork.cc (frok::parent): Drop fixup_before handling. * spawn.cc (spawn_guts): Ditto. --- winsup/cygwin/ChangeLog | 17 +++++++++++++++++ winsup/cygwin/dtable.cc | 32 -------------------------------- winsup/cygwin/dtable.h | 12 +----------- winsup/cygwin/fhandler.h | 2 -- winsup/cygwin/fork.cc | 15 --------------- winsup/cygwin/spawn.cc | 8 +------- 6 files changed, 19 insertions(+), 67 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index f0585d883..5b8e7ae6d 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,20 @@ +2008-04-30 Corinna Vinschen + + * dtable.cc (dtable::release): Drop fixup_before handling. + (dtable::fixup_before_fork): Remove. + (dtable::fixup_before_exec): Remove. + * dtable.h (class dtable): Remove cnt_need_fixup_before member. + (dtable::dtable): Accommodate above change. + (dtable::dec_need_fixup_before): Remove. + (dtable::inc_need_fixup_before): Remove. + (dtable::need_fixup_before): Remove. + (dtable::fixup_before_exec): Remove declaration. + (dtable::fixup_before_fork): Ditto. + * fhandler.h (fhandler_base::fixup_before_fork_exec): Remove. + (fhandler_base::need_fixup_before): Remove. + * fork.cc (frok::parent): Drop fixup_before handling. + * spawn.cc (spawn_guts): Ditto. + 2008-04-30 Corinna Vinschen * mount.cc (is_unc_share): Allow \\?\ prefix as well. Enhance comment. diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc index d3cc71917..2192bcf09 100644 --- a/winsup/cygwin/dtable.cc +++ b/winsup/cygwin/dtable.cc @@ -236,8 +236,6 @@ dtable::release (int fd) { if (!not_open (fd)) { - if (fds[fd]->need_fixup_before ()) - dec_need_fixup_before (); fhandler_base *arch = fds[fd]->archetype; delete fds[fd]; if (arch && !arch->usecount) @@ -672,22 +670,6 @@ dtable::select_except (int fd, select_record *s) return s; } -/* Function to walk the fd table after an exec and perform - per-fhandler type fixups. */ -void -dtable::fixup_before_fork (DWORD target_proc_id) -{ - lock (); - fhandler_base *fh; - for (size_t i = 0; i < size; i++) - if ((fh = fds[i]) != NULL) - { - debug_printf ("fd %d (%s)", i, fh->get_name ()); - fh->fixup_before_fork_exec (target_proc_id); - } - unlock (); -} - void dtable::move_fd (int from, int to) { @@ -696,20 +678,6 @@ dtable::move_fd (int from, int to) fds[from] = NULL; } -void -dtable::fixup_before_exec (DWORD target_proc_id) -{ - lock (); - fhandler_base *fh; - for (size_t i = 0; i < size; i++) - if ((fh = fds[i]) != NULL && !fh->close_on_exec ()) - { - debug_printf ("fd %d (%s)", i, fh->get_name ()); - fh->fixup_before_fork_exec (target_proc_id); - } - unlock (); -} - void dtable::set_file_pointers_for_exec () { diff --git a/winsup/cygwin/dtable.h b/winsup/cygwin/dtable.h index ff82740dc..9940292a5 100644 --- a/winsup/cygwin/dtable.h +++ b/winsup/cygwin/dtable.h @@ -28,30 +28,20 @@ class dtable unsigned farchetype; static const int initial_archetype_size = 8; int first_fd_for_open; - int cnt_need_fixup_before; void lock () {lock_process::locker.acquire ();} void unlock () {lock_process::locker.release ();} public: size_t size; - dtable () : archetypes (NULL), narchetypes (0), farchetype (0), first_fd_for_open(3), cnt_need_fixup_before(0) {} + dtable () : archetypes (NULL), narchetypes (0), farchetype (0), first_fd_for_open(3) {} void init () {first_fd_for_open = 3;} - void dec_need_fixup_before () - { if (cnt_need_fixup_before > 0) --cnt_need_fixup_before; } - void inc_need_fixup_before () - { cnt_need_fixup_before++; } - bool need_fixup_before () - { return cnt_need_fixup_before > 0; } - void move_fd (int, int); int vfork_child_dup (); void vfork_parent_restore (); void vfork_child_fixup (); fhandler_base *dup_worker (fhandler_base *oldfh); int extend (int howmuch); - void fixup_before_exec (DWORD win_proc_id); - void fixup_before_fork (DWORD win_proc_id); void fixup_after_fork (HANDLE); inline int not_open (int fd) { diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index 259a0f450..ee08ccd9f 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -218,7 +218,6 @@ class fhandler_base return close_on_exec () ? &sec_none_nih : &sec_none; } - virtual void fixup_before_fork_exec (DWORD) {} virtual void fixup_after_fork (HANDLE); virtual void fixup_after_exec (); void create_read_state (LONG n) @@ -263,7 +262,6 @@ class fhandler_base /* fixup fd possibly non-inherited handles after fork */ bool fork_fixup (HANDLE, HANDLE &, const char *); - virtual bool need_fixup_before () const {return false;} virtual int open (int, mode_t = 0); int open_fs (int, mode_t = 0); diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc index fa80c6922..742f1e7f8 100644 --- a/winsup/cygwin/fork.cc +++ b/winsup/cygwin/fork.cc @@ -310,13 +310,6 @@ frok::parent (volatile char * volatile stack_here) else c_flags |= DETACHED_PROCESS; - /* Some file types (currently only sockets) need extra effort in the - parent after CreateProcess and before copying the datastructures - to the child. So we have to start the child in suspend state, - unfortunately, to avoid a race condition. */ - if (cygheap->fdtab.need_fixup_before ()) - c_flags |= CREATE_SUSPENDED; - /* Remember the address of the first loaded dll and decide if we need to load dlls. We do this here so that this information will be available in the parent and, when @@ -389,14 +382,6 @@ frok::parent (volatile char * volatile stack_here) goto cleanup; } - /* Fixup the parent datastructure if needed and resume the child's - main thread. */ - if (c_flags & CREATE_SUSPENDED) - { - cygheap->fdtab.fixup_before_fork (pi.dwProcessId); - ResumeThread (pi.hThread); - } - CloseHandle (pi.hThread); /* Protect the handle but name it similarly to the way it will diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index e4baadef0..a5856489a 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -502,8 +502,7 @@ spawn_guts (const char *prog_arg, const char *const *argv, and before copying the datastructures to the child. So we have to start the child in suspend state, unfortunately, to avoid a race condition. */ if (!newargv.win16_exe - && (!ch.iscygwin () || mode != _P_OVERLAY - || cygheap->fdtab.need_fixup_before ())) + && (!ch.iscygwin () || mode != _P_OVERLAY)) c_flags |= CREATE_SUSPENDED; /* When ruid != euid we create the new process under the current original @@ -628,11 +627,6 @@ loop: if (!(c_flags & CREATE_SUSPENDED)) strace.write_childpid (ch, pi.dwProcessId); - /* Fixup the parent data structures if needed and resume the child's - main thread. */ - if (cygheap->fdtab.need_fixup_before ()) - cygheap->fdtab.fixup_before_exec (pi.dwProcessId); - if (mode != _P_OVERLAY) cygpid = cygwin_pid (pi.dwProcessId); else