diff options
Diffstat (limited to 'gpg_wrapper.cpp')
-rw-r--r-- | gpg_wrapper.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/gpg_wrapper.cpp b/gpg_wrapper.cpp index 226fd5e..a6c2723 100644 --- a/gpg_wrapper.cpp +++ b/gpg_wrapper.cpp @@ -18,12 +18,12 @@ //thx gpg module from Harald Treder, Zakhar V. Bardymov -HANDLE gpg_mutex = NULL; +boost::mutex gpg_mutex; pxResult pxExecute(wstring *acommandline, char *ainput, string *aoutput, LPDWORD aexitcode, pxResult *result) { - WaitForSingleObject(gpg_mutex, INFINITE); + gpg_mutex.lock(); extern logtofile debuglog; BOOL success; STARTUPINFO sinfo = {0}; @@ -99,7 +99,6 @@ pxResult pxExecute(wstring *acommandline, char *ainput, string *aoutput, LPDWORD debuglog<<"gpg in: "<<commandline<<"\n"; - gpg_mutex = CreateMutex(NULL, FALSE, NULL); success = CreateProcess(NULL, (TCHAR*)commandline.c_str(), NULL, NULL, TRUE, CREATE_NEW_CONSOLE | CREATE_UNICODE_ENVIRONMENT, _T("LANGUAGE=en@quot\0"), NULL, &sinfo, &pri); if (!success) @@ -108,7 +107,7 @@ pxResult pxExecute(wstring *acommandline, char *ainput, string *aoutput, LPDWORD CloseHandle(writestdin); CloseHandle(newstdout); CloseHandle(readstdout); - ReleaseMutex(gpg_mutex); + gpg_mutex.unlock(); *result = pxCreateProcessFailed; return pxCreateProcessFailed; } @@ -130,7 +129,7 @@ pxResult pxExecute(wstring *acommandline, char *ainput, string *aoutput, LPDWORD inputpos+=transfered; Sleep(200); } - ReleaseMutex(gpg_mutex); + gpg_mutex.unlock(); storeOutput(readstdout,aoutput); |