diff options
author | Gluzskiy Alexandr <sss123next@list.ru> | 2010-08-31 02:22:05 +0300 |
---|---|---|
committer | Gluzskiy Alexandr <sss123next@list.ru> | 2010-08-31 02:22:05 +0300 |
commit | afe644994d365883bb683cdaf79e383259632d6e (patch) | |
tree | f4cab816e85dba7dfe9ad9417e3b79b366c7a5c7 /messages.cpp | |
parent | c5cc46ceb67eb92ebf1ca1094e48d5938d5f7d1a (diff) |
more or less thread save code
Diffstat (limited to 'messages.cpp')
-rw-r--r-- | messages.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/messages.cpp b/messages.cpp index 8a909c1..15972e4 100644 --- a/messages.cpp +++ b/messages.cpp @@ -19,6 +19,7 @@ wstring new_key; HANDLE new_key_hcnt = NULL; +HANDLE new_key_hcnt_mutex = NULL; bool _terminate = false; BOOL isProtoMetaContacts(HANDLE hContact); @@ -78,6 +79,8 @@ int RecvMsgSvc(WPARAM w, LPARAM l) s2 += _tcslen(_T("-----END PGP PRIVATE KEY BLOCK-----")); } new_key.append(str.substr(s1,s2-s1)); + WaitForSingleObject(new_key_hcnt_mutex, INFINITE); + new_key_hcnt_mutex = CreateMutex(NULL, FALSE, NULL); new_key_hcnt = hContact; ShowNewKeyDialog(); return CallService(MS_PROTO_CHAINRECV, w, l); @@ -204,6 +207,8 @@ int RecvMsgSvc(WPARAM w, LPARAM l) DBWriteContactSettingString(hContact, szGPGModuleName, "InKeyID", out.substr(s, s2-s).c_str()); } void ShowLoadKeyPasswordWindow(); + WaitForSingleObject(new_key_hcnt_mutex, INFINITE); + new_key_hcnt_mutex = CreateMutex(NULL, FALSE, NULL); new_key_hcnt = hContact; ShowLoadKeyPasswordWindow(); wstring cmd2 = cmd; @@ -513,6 +518,7 @@ int TestHook(WPARAM w, LPARAM l) static BOOL CALLBACK DlgProcKeyPassword(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { HANDLE hContact = new_key_hcnt; + CloseHandle(new_key_hcnt_mutex); TCHAR *tmp = NULL; char *inkeyid = UniGetContactSettingUtf(hContact, szGPGModuleName, "InKeyID", ""); switch (msg) |