summaryrefslogtreecommitdiff
path: root/gpg_wrapper.cpp
diff options
context:
space:
mode:
authorGluzskiy Alexandr <sss123next@list.ru>2010-10-08 07:01:44 +0300
committerGluzskiy Alexandr <sss123next@list.ru>2010-10-08 07:01:44 +0300
commitd5721b974a58ed5a26f33346dae728d93a7c1803 (patch)
tree2679ec39d8a44b5c3bdaf947d21881135460e7b7 /gpg_wrapper.cpp
parent7df7cc0f3a8435c18e4491b04827deb47078b6d5 (diff)
boost threads and mutexes, better error handling (thread's timeouts)
Diffstat (limited to 'gpg_wrapper.cpp')
-rw-r--r--gpg_wrapper.cpp9
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);