Skip to content
Snippets Groups Projects
Commit 0fa6774a authored by rswindell's avatar rswindell
Browse files

Fixed bug in external() on NT-based oses, now that the Win32 pthread_mutex

implementation uses CriticalSections, it would lock the input_thread by leaving
(releasing) the critical section when it didn't own it.
parent fa75faa0
No related branches found
No related tags found
No related merge requests found
...@@ -253,6 +253,7 @@ int sbbs_t::external(char* cmdline, long mode, char* startup_dir) ...@@ -253,6 +253,7 @@ int sbbs_t::external(char* cmdline, long mode, char* startup_dir)
bool was_online=true; bool was_online=true;
bool rio_abortable_save; bool rio_abortable_save;
bool use_pipes=false; // NT-compatible console redirection bool use_pipes=false; // NT-compatible console redirection
bool input_thread_mutex_locked=false;
uint i; uint i;
time_t hungup=0; time_t hungup=0;
HANDLE vxd=INVALID_HANDLE_VALUE; HANDLE vxd=INVALID_HANDLE_VALUE;
...@@ -555,8 +556,10 @@ int sbbs_t::external(char* cmdline, long mode, char* startup_dir) ...@@ -555,8 +556,10 @@ int sbbs_t::external(char* cmdline, long mode, char* startup_dir)
fclose(fp); fclose(fp);
/* not temporary */ /* not temporary */
if(!(mode&EX_INR)) if(!(mode&EX_INR)) {
pthread_mutex_lock(&input_thread_mutex); pthread_mutex_lock(&input_thread_mutex);
input_thread_mutex_locked=true;
}
} }
if(!CreateProcess( if(!CreateProcess(
...@@ -572,7 +575,7 @@ int sbbs_t::external(char* cmdline, long mode, char* startup_dir) ...@@ -572,7 +575,7 @@ int sbbs_t::external(char* cmdline, long mode, char* startup_dir)
&process_info // pointer to PROCESS_INFORMATION &process_info // pointer to PROCESS_INFORMATION
)) { )) {
XTRN_CLEANUP; XTRN_CLEANUP;
if(native && !(mode&EX_OFFLINE)) if(input_thread_mutex_locked)
pthread_mutex_unlock(&input_thread_mutex); pthread_mutex_unlock(&input_thread_mutex);
SetLastError(last_error); /* Restore LastError */ SetLastError(last_error); /* Restore LastError */
errormsg(WHERE, ERR_EXEC, realcmdline, mode); errormsg(WHERE, ERR_EXEC, realcmdline, mode);
...@@ -921,7 +924,8 @@ int sbbs_t::external(char* cmdline, long mode, char* startup_dir) ...@@ -921,7 +924,8 @@ int sbbs_t::external(char* cmdline, long mode, char* startup_dir)
if(native) { if(native) {
ulong l=0; ulong l=0;
ioctlsocket(client_socket, FIONBIO, &l); ioctlsocket(client_socket, FIONBIO, &l);
pthread_mutex_unlock(&input_thread_mutex); if(input_thread_mutex_locked)
pthread_mutex_unlock(&input_thread_mutex);
} }
curatr=~0; // Can't guarantee current attributes curatr=~0; // Can't guarantee current attributes
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment