* cygheap.h (class process_lock): New class.
* dtable.h (class dtable): Add class process_lock as a friend. * dcrt0.cc (get_exit_lock): Delete. (do_exit): Use process_lock class instead of get_exit_lock. * exceptions.cc (signal_exit): Ditto. * pinfo.cc (pinfo::exit): Ditto. (_pinfo::commune_process): Set process lock around this whole function. (_pinfo::commune_request): Use process_lock rather than myself.lock. * pinfo.h (pinfo::_lock): Delete. (pinfo::initialize_lock): Delete. (pinfo::lock): Delete. (pinfo::unlock): Delete. * winsup.h (get_exit_lock): Delete declaration.
This commit is contained in:
		| @@ -1,3 +1,20 @@ | |||||||
|  | 2005-10-03  Christopher Faylor  <cgf@timesys.com> | ||||||
|  |  | ||||||
|  | 	* cygheap.h (class process_lock): New class. | ||||||
|  | 	* dtable.h (class dtable): Add class process_lock as a friend. | ||||||
|  | 	* dcrt0.cc (get_exit_lock): Delete. | ||||||
|  | 	(do_exit): Use process_lock class instead of get_exit_lock. | ||||||
|  | 	* exceptions.cc (signal_exit): Ditto. | ||||||
|  | 	* pinfo.cc (pinfo::exit): Ditto. | ||||||
|  | 	(_pinfo::commune_process): Set process lock around this whole function. | ||||||
|  | 	(_pinfo::commune_request): Use process_lock rather than myself.lock. | ||||||
|  | 	* pinfo.h (pinfo::_lock): Delete. | ||||||
|  | 	(pinfo::initialize_lock): Delete. | ||||||
|  | 	(pinfo::lock): Delete. | ||||||
|  | 	(pinfo::unlock): Delete. | ||||||
|  | 	* winsup.h (get_exit_lock): Delete declaration. | ||||||
|  | 	 | ||||||
|  |  | ||||||
| 2005-10-03  Corinna Vinschen  <corinna@vinschen.de> | 2005-10-03  Corinna Vinschen  <corinna@vinschen.de> | ||||||
|  |  | ||||||
| 	* uname.cc (uname): Disable use of GetNativeSystemInfo. | 	* uname.cc (uname): Disable use of GetNativeSystemInfo. | ||||||
|   | |||||||
| @@ -415,6 +415,27 @@ class cygheap_fdenum : public cygheap_fdmanip | |||||||
|   } |   } | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | class process_lock | ||||||
|  | { | ||||||
|  |   bool skip_unlock; | ||||||
|  | public: | ||||||
|  |   process_lock (bool exiting = false) | ||||||
|  |   { | ||||||
|  |     cygheap->fdtab.lock (); | ||||||
|  |     skip_unlock = exiting; | ||||||
|  |     if (exiting && exit_state < ES_SET_MUTO) | ||||||
|  |       { | ||||||
|  | 	exit_state = ES_SET_MUTO; | ||||||
|  | 	muto::set_exiting_thread (); | ||||||
|  |       } | ||||||
|  |   } | ||||||
|  |   ~process_lock () | ||||||
|  |   { | ||||||
|  |     if (!skip_unlock) | ||||||
|  |       cygheap->fdtab.unlock (); | ||||||
|  |   } | ||||||
|  | }; | ||||||
|  |  | ||||||
| class child_info; | class child_info; | ||||||
| void __stdcall cygheap_fixup_in_child (bool); | void __stdcall cygheap_fixup_in_child (bool); | ||||||
| extern "C" { | extern "C" { | ||||||
|   | |||||||
| @@ -1021,7 +1021,7 @@ do_exit (int status) | |||||||
|     } |     } | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|   get_exit_lock (); |   process_lock until_exit (true); | ||||||
|  |  | ||||||
|   if (exit_state < ES_GLOBAL_DTORS) |   if (exit_state < ES_GLOBAL_DTORS) | ||||||
|     { |     { | ||||||
| @@ -1138,17 +1138,6 @@ _exit (int n) | |||||||
|   do_exit (((DWORD) n & 0xff) << 8); |   do_exit (((DWORD) n & 0xff) << 8); | ||||||
| } | } | ||||||
|  |  | ||||||
| void |  | ||||||
| get_exit_lock () |  | ||||||
| { |  | ||||||
|   myself.lock (); |  | ||||||
|   if (exit_state < ES_SET_MUTO) |  | ||||||
|     { |  | ||||||
|       exit_state = ES_SET_MUTO; |  | ||||||
|       muto::set_exiting_thread (); |  | ||||||
|     } |  | ||||||
| } |  | ||||||
|  |  | ||||||
| extern "C" void | extern "C" void | ||||||
| __api_fatal (const char *fmt, ...) | __api_fatal (const char *fmt, ...) | ||||||
| { | { | ||||||
|   | |||||||
| @@ -89,6 +89,7 @@ public: | |||||||
|   friend class cygheap_fdget; |   friend class cygheap_fdget; | ||||||
|   friend class cygheap_fdnew; |   friend class cygheap_fdnew; | ||||||
|   friend class cygheap_fdenum; |   friend class cygheap_fdenum; | ||||||
|  |   friend class process_lock; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| fhandler_base *build_fh_dev (const device&, const char * = NULL); | fhandler_base *build_fh_dev (const device&, const char * = NULL); | ||||||
|   | |||||||
| @@ -26,6 +26,10 @@ details. */ | |||||||
| #include "shared_info.h" | #include "shared_info.h" | ||||||
| #include "perprocess.h" | #include "perprocess.h" | ||||||
| #include "security.h" | #include "security.h" | ||||||
|  | #include "path.h" | ||||||
|  | #include "fhandler.h" | ||||||
|  | #include "dtable.h" | ||||||
|  | #include "cygheap.h" | ||||||
|  |  | ||||||
| #define CALL_HANDLER_RETRY 20 | #define CALL_HANDLER_RETRY 20 | ||||||
|  |  | ||||||
| @@ -1179,7 +1183,7 @@ signal_exit (int rc) | |||||||
|       TerminateProcess (hExeced, sigExeced = rc); |       TerminateProcess (hExeced, sigExeced = rc); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   get_exit_lock (); |   process_lock until_exit (true); | ||||||
|   if (hExeced || exit_state) |   if (hExeced || exit_state) | ||||||
|     myself.exit (rc); |     myself.exit (rc); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -59,7 +59,6 @@ set_myself (HANDLE h) | |||||||
| #endif | #endif | ||||||
|     strace.hello (); |     strace.hello (); | ||||||
|   debug_printf ("myself->dwProcessId %u", myself->dwProcessId); |   debug_printf ("myself->dwProcessId %u", myself->dwProcessId); | ||||||
|   myself.initialize_lock (); |  | ||||||
|   if (h) |   if (h) | ||||||
|     { |     { | ||||||
|       /* here if execed */ |       /* here if execed */ | ||||||
| @@ -140,7 +139,7 @@ pinfo::zap_cwd () | |||||||
| void | void | ||||||
| pinfo::exit (DWORD n) | pinfo::exit (DWORD n) | ||||||
| { | { | ||||||
|   get_exit_lock (); |   process_lock until_exit (); | ||||||
|   cygthread::terminate (); |   cygthread::terminate (); | ||||||
|   if (n != EXITCODE_NOSET) |   if (n != EXITCODE_NOSET) | ||||||
|     self->exitcode = EXITCODE_SET | n;/* We're really exiting.  Record the UNIX exit code. */ |     self->exitcode = EXITCODE_SET | n;/* We're really exiting.  Record the UNIX exit code. */ | ||||||
| @@ -390,6 +389,8 @@ _pinfo::commune_process (siginfo_t& si) | |||||||
|   if (process_sync)		// FIXME: this test shouldn't be necessary |   if (process_sync)		// FIXME: this test shouldn't be necessary | ||||||
|     ProtectHandle (process_sync); |     ProtectHandle (process_sync); | ||||||
|  |  | ||||||
|  |   process_lock now (false); | ||||||
|  |  | ||||||
|   switch (si._si_commune._si_code) |   switch (si._si_commune._si_code) | ||||||
|     { |     { | ||||||
|     case PICOM_CMDLINE: |     case PICOM_CMDLINE: | ||||||
| @@ -586,7 +587,7 @@ _pinfo::commune_request (__uint32_t code, ...) | |||||||
|     break; |     break; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   myself.lock (); |   process_lock now (); | ||||||
|   locked = true; |   locked = true; | ||||||
|   char name_buf[CYG_MAX_PATH]; |   char name_buf[CYG_MAX_PATH]; | ||||||
|   request_sync = CreateSemaphore (&sec_none_nih, 0, LONG_MAX, |   request_sync = CreateSemaphore (&sec_none_nih, 0, LONG_MAX, | ||||||
| @@ -665,8 +666,6 @@ out: | |||||||
|       ReleaseSemaphore (request_sync, 1, &res); |       ReleaseSemaphore (request_sync, 1, &res); | ||||||
|       ForceCloseHandle (request_sync); |       ForceCloseHandle (request_sync); | ||||||
|     } |     } | ||||||
|   if (locked) |  | ||||||
|     myself.unlock (); |  | ||||||
|   if (hp) |   if (hp) | ||||||
|     CloseHandle (hp); |     CloseHandle (hp); | ||||||
|   if (fromthem) |   if (fromthem) | ||||||
|   | |||||||
| @@ -149,7 +149,6 @@ class pinfo | |||||||
| public: | public: | ||||||
|   HANDLE rd_proc_pipe; |   HANDLE rd_proc_pipe; | ||||||
|   HANDLE hProcess; |   HANDLE hProcess; | ||||||
|   CRITICAL_SECTION _lock; |  | ||||||
|   bool waiter_ready; |   bool waiter_ready; | ||||||
|   class cygthread *wait_thread; |   class cygthread *wait_thread; | ||||||
|   void init (pid_t, DWORD, HANDLE) __attribute__ ((regparm(3))); |   void init (pid_t, DWORD, HANDLE) __attribute__ ((regparm(3))); | ||||||
| @@ -166,9 +165,6 @@ public: | |||||||
|   } |   } | ||||||
|   void exit (DWORD n) __attribute__ ((noreturn, regparm(2))); |   void exit (DWORD n) __attribute__ ((noreturn, regparm(2))); | ||||||
|   void maybe_set_exit_code_from_windows () __attribute__ ((regparm(1))); |   void maybe_set_exit_code_from_windows () __attribute__ ((regparm(1))); | ||||||
|   void initialize_lock () {InitializeCriticalSection (&_lock);} |  | ||||||
|   void lock () {EnterCriticalSection (&_lock);} |  | ||||||
|   void unlock () {LeaveCriticalSection (&_lock);} |  | ||||||
|   _pinfo *operator -> () const {return procinfo;} |   _pinfo *operator -> () const {return procinfo;} | ||||||
|   int operator == (pinfo *x) const {return x->procinfo == procinfo;} |   int operator == (pinfo *x) const {return x->procinfo == procinfo;} | ||||||
|   int operator == (pinfo &x) const {return x.procinfo == procinfo;} |   int operator == (pinfo &x) const {return x.procinfo == procinfo;} | ||||||
|   | |||||||
| @@ -203,7 +203,6 @@ enum exit_states | |||||||
|  |  | ||||||
| extern exit_states exit_state; | extern exit_states exit_state; | ||||||
| void __stdcall do_exit (int) __attribute__ ((regparm (1), noreturn)); | void __stdcall do_exit (int) __attribute__ ((regparm (1), noreturn)); | ||||||
| void __stdcall get_exit_lock (); |  | ||||||
|  |  | ||||||
| /* UID/GID */ | /* UID/GID */ | ||||||
| void uinfo_init (); | void uinfo_init (); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user