From 8174eb73282e177112615c2dd332b69401959764 Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Wed, 30 Mar 2011 08:51:28 +0300 Subject: one more threading variant (without mutexes) --- messages.cpp | 63 +++++++++++++++++++++--------------------------------------- 1 file changed, 22 insertions(+), 41 deletions(-) (limited to 'messages.cpp') diff --git a/messages.cpp b/messages.cpp index ef6cf97..3426b5e 100644 --- a/messages.cpp +++ b/messages.cpp @@ -19,7 +19,7 @@ wstring new_key; HANDLE new_key_hcnt = NULL; -boost::mutex new_key_hcnt_mutex, gpg_file_mutex; +boost::mutex new_key_hcnt_mutex; bool _terminate = false; int returnNoError(HANDLE hContact); @@ -78,10 +78,11 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags) char *tmp = mir_t2a(str.substr(s1,s2-s1).c_str()); TCHAR *tmp2 = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", _T("")); wstring path = tmp2; - path.append(_T("\\encrypted_data.asc")); + wstring encfile = toUTF16(get_random(10)); + wstring decfile = toUTF16(get_random(10)); + path.append(_T("\\tmp\\")); + path.append(encfile); DeleteFile(path.c_str()); - while(!gpg_file_mutex.timed_lock(boost::posix_time::seconds(15))) - gpg_file_mutex.unlock(); fstream f(path.c_str(), std::ios::out); while(!f.is_open()) f.open(path.c_str(), std::ios::out); @@ -132,12 +133,15 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags) } { wstring path = tmp2; - path += _T("\\decrypted_data"); + path += _T("\\tmp\\"); + path += decfile; DeleteFile(path.c_str()); } cmd += _T("--output \""); cmd += tmp2; - cmd += _T("\\decrypted_data\""); + cmd += _T("\\tmp\\"); + cmd += decfile; + cmd += _T("\""); cmd += _T(" -d -a \""); cmd += path; cmd += _T("\""); @@ -155,14 +159,12 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags) debuglog<