* exceptions.cc (call_handler): Streamline to use only one call to
ResumeThread. * sigproc.cc (sig_send): Use a muto around the ReleaseSemaphore. Remove priority setting since it didn't solve anything.
This commit is contained in:
		| @@ -1,3 +1,10 @@ | ||||
| Sun Mar  5 01:17:05 2000  Christopher Faylor <cgf@cygnus.com> | ||||
|  | ||||
| 	* exceptions.cc (call_handler): Streamline to use only one call to | ||||
| 	ResumeThread. | ||||
| 	* sigproc.cc (sig_send): Use a muto around the ReleaseSemaphore. | ||||
| 	Remove priority setting since it didn't solve anything. | ||||
|  | ||||
| Tue Feb 29 00:46:09 2000  Christopher Faylor <cgf@cygnus.com> | ||||
|  | ||||
| 	* sigproc.cc (sig_send): Temporarily set priority to highest while | ||||
|   | ||||
| @@ -719,7 +719,7 @@ call_handler (int sig, struct sigaction& siga, void *handler) | ||||
|       SetEvent (signal_arrived);	// For an EINTR case | ||||
|       sigproc_printf ("armed signal_arrived"); | ||||
|       exec_exit = sig;			// Maybe we'll exit with this value | ||||
|       goto out; | ||||
|       goto out1; | ||||
|     } | ||||
|   hth = myself->getthread2signal (); | ||||
|  | ||||
| @@ -749,7 +749,7 @@ call_handler (int sig, struct sigaction& siga, void *handler) | ||||
|       Sleep (0); | ||||
|     } | ||||
|  | ||||
|   sigproc_printf ("suspend said %d, %E", res); | ||||
|   sigproc_printf ("SuspendThread returned %d", res); | ||||
|  | ||||
|   if (sigsave.cx) | ||||
|     { | ||||
| @@ -764,7 +764,6 @@ call_handler (int sig, struct sigaction& siga, void *handler) | ||||
|       if (!GetThreadContext (hth, cx)) | ||||
| 	{ | ||||
| 	  system_printf ("couldn't get context of main thread, %E"); | ||||
| 	  ResumeThread (hth); | ||||
| 	  goto out; | ||||
| 	} | ||||
|     } | ||||
| @@ -787,9 +786,11 @@ call_handler (int sig, struct sigaction& siga, void *handler) | ||||
|       proc_subproc(PROC_CLEARWAIT, 1); | ||||
|     } | ||||
|  | ||||
|   (void) ResumeThread (hth); | ||||
|  | ||||
| out: | ||||
|   res = ResumeThread (hth); | ||||
|   sigproc_printf ("ResumeThread returned %d", res); | ||||
|  | ||||
| out1: | ||||
|   sigproc_printf ("returning %d", interrupted); | ||||
|   return interrupted; | ||||
| } | ||||
| @@ -1046,6 +1047,9 @@ events_init (void) | ||||
|       *end = '\0'; | ||||
|     } | ||||
|   windows_system_directory_length = end - windows_system_directory; | ||||
|   debug_printf ("windows_system_directory '%s', windows_system_directory_length %d", | ||||
| 		windows_system_directory, windows_system_directory_length); | ||||
|   debug_printf ("cygwin_hmodule %p", cygwin_hmodule); | ||||
| } | ||||
|  | ||||
| void | ||||
|   | ||||
| @@ -99,8 +99,8 @@ Static int nzombies = 0;		// Number of deceased children | ||||
| Static waitq waitq_head = {0, 0, 0, 0, 0, 0, 0};// Start of queue for wait'ing threads | ||||
| Static waitq waitq_main;		// Storage for main thread | ||||
|  | ||||
| muto NO_COPY *sync_proc_subproc = NULL;	// Control access to | ||||
| 					//  subproc stuff | ||||
| muto NO_COPY *sync_proc_subproc = NULL;	// Control access to subproc stuff | ||||
| muto NO_COPY *sync_sig_send = NULL;	// Control access to sig_send | ||||
|  | ||||
| DWORD NO_COPY maintid = 0;		// ID of the main thread | ||||
| DWORD NO_COPY sigtid = 0;		// ID of the signal thread | ||||
| @@ -618,6 +618,7 @@ sigproc_init () | ||||
|    * access to the children and zombie arrays. | ||||
|    */ | ||||
|   sync_proc_subproc = new_muto (FALSE, NULL); | ||||
|   sync_sig_send = new_muto (FALSE, NULL); | ||||
|  | ||||
|   /* Initialize waitq structure for main thread.  A waitq structure is | ||||
|    * allocated for each thread that executes a wait to allow multiple threads | ||||
| @@ -770,18 +771,25 @@ sig_send (pinfo *p, int sig) | ||||
|   if (sd == NULL) | ||||
|     sd = signal_dispatch_storage.create (); | ||||
| #endif | ||||
|  | ||||
|   sync_sig_send->acquire (); | ||||
|   /* Increment the sigtodo array to signify which signal to assert. | ||||
|    */ | ||||
|   (void) InterlockedIncrement (p->getsigtodo(sig)); | ||||
|  | ||||
|   /* Notify the process that a signal has arrived. | ||||
|    */ | ||||
|   int prio; | ||||
|   SetLastError (0); | ||||
|  | ||||
| #if 0 | ||||
|   int prio; | ||||
|   prio = GetThreadPriority (GetCurrentThread ()); | ||||
|   (void) SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_TIME_CRITICAL); | ||||
| #endif | ||||
|  | ||||
|   if (!ReleaseSemaphore (thiscatch, 1, NULL) && (int) GetLastError () > 0) | ||||
|     { | ||||
| sigproc_printf ("ReleaseSemaphore failed, %E"); | ||||
|       /* Couldn't signal the semaphore.  This probably means that the | ||||
|        * process is exiting. | ||||
|        */ | ||||
| @@ -799,6 +807,7 @@ sig_send (pinfo *p, int sig) | ||||
| 	} | ||||
|       goto out; | ||||
|     } | ||||
| sigproc_printf ("ReleaseSemaphore succeeded"); | ||||
|  | ||||
|   /* No need to wait for signal completion unless this was a signal to | ||||
|    * this process. | ||||
| @@ -811,6 +820,7 @@ sig_send (pinfo *p, int sig) | ||||
|     { | ||||
|       rc = WAIT_OBJECT_0; | ||||
|       sip_printf ("Not waiting for sigcomplete.  its_me %d sig %d", its_me, sig); | ||||
|       sync_sig_send->release (); | ||||
|       if (!its_me) | ||||
| 	ForceCloseHandle (thiscatch); | ||||
|     } | ||||
| @@ -819,6 +829,8 @@ sig_send (pinfo *p, int sig) | ||||
|       sip_printf ("Waiting for thiscomplete %p", thiscomplete); | ||||
|  | ||||
|       SetLastError (0); | ||||
|       sync_sig_send->release (); | ||||
| Sleep (0); | ||||
|       rc = WaitForSingleObject (thiscomplete, WSSC); | ||||
|       /* Check for strangeness due to this thread being redirected by the | ||||
| 	 signal handler.  Sometimes a WAIT_TIMEOUT will occur when the | ||||
| @@ -829,7 +841,9 @@ sig_send (pinfo *p, int sig) | ||||
| 	rc = WAIT_OBJECT_0; | ||||
|     } | ||||
|  | ||||
| #if 0 | ||||
|   SetThreadPriority (GetCurrentThread (), prio); | ||||
| #endif | ||||
|  | ||||
|   if (rc == WAIT_OBJECT_0) | ||||
|     rc = 0;		// Successful exit | ||||
|   | ||||
		Reference in New Issue
	
	Block a user