diff options
Diffstat (limited to 'utilities.cpp')
-rw-r--r-- | utilities.cpp | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/utilities.cpp b/utilities.cpp index 271afb2..2ad4cf2 100644 --- a/utilities.cpp +++ b/utilities.cpp @@ -517,10 +517,10 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, HXML node, void *pU params.out = &out; params.code = &code; params.result = &result; - HANDLE gpg_thread = mir_forkthread(pxEexcute_thread, (void*)¶ms); - if(WaitForSingleObject(gpg_thread, 10000) == WAIT_TIMEOUT) + boost::thread gpg_thread(boost::bind(&pxEexcute_thread, ¶ms)); + if(!gpg_thread.timed_join(boost::posix_time::seconds(10))) { - TerminateThread(gpg_thread, 0); + gpg_thread.~thread(); MessageBox(0, _T("GPG execution timed out, aborted"), _T(""), MB_OK); } if(result == pxNotFound) @@ -590,7 +590,7 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, HXML node, void *pU return FALSE; } -HANDLE sign_file_mutex = NULL; +boost::mutex sign_file_mutex; static JABBER_HANDLER_FUNC PrescenseHandler(IJabberInterface *ji, HXML node, void *pUserData) { @@ -617,8 +617,7 @@ static JABBER_HANDLER_FUNC PrescenseHandler(IJabberInterface *ji, HXML node, voi wstring path_out = path_c; mir_free(path_c); path_out += _T("\\sign.asc"); - WaitForSingleObject(sign_file_mutex, INFINITE); - sign_file_mutex = CreateMutex(NULL, FALSE, NULL); + sign_file_mutex.lock(); DeleteFile(path_out.c_str()); wfstream f(path_out.c_str(), std::ios::out); char *tmp = mir_utf8encodeW(sign.c_str()); @@ -629,7 +628,7 @@ static JABBER_HANDLER_FUNC PrescenseHandler(IJabberInterface *ji, HXML node, voi { if(errno == ENOENT) { - ReleaseMutex(sign_file_mutex); + sign_file_mutex.unlock(); debuglog<<"info: Failed to write sign in file\n"; return FALSE; } @@ -647,14 +646,14 @@ static JABBER_HANDLER_FUNC PrescenseHandler(IJabberInterface *ji, HXML node, voi params.out = &out; params.code = &code; params.result = &result; - HANDLE gpg_thread = mir_forkthread(pxEexcute_thread, (void*)¶ms); - if(WaitForSingleObject(gpg_thread, 10000) == WAIT_TIMEOUT) + boost::thread gpg_thread(boost::bind(&pxEexcute_thread, ¶ms)); + if(!gpg_thread.timed_join(boost::posix_time::seconds(10))) { - TerminateThread(gpg_thread, 0); + gpg_thread.~thread(); MessageBox(0, _T("GPG execution timed out, aborted"), _T(""), MB_OK); } DeleteFile(path_out.c_str()); - ReleaseMutex(sign_file_mutex); + sign_file_mutex.unlock(); if(result == pxNotFound) { MessageBox(0, _T("Set path to gpg.exe first!"), _T("Warning"), MB_OK); |