summaryrefslogtreecommitdiff
path: root/plugins/New_GPG
diff options
context:
space:
mode:
authorAlexander Gluzsky <sss123next@list.ru>2015-12-17 17:21:07 +0000
committerAlexander Gluzsky <sss123next@list.ru>2015-12-17 17:21:07 +0000
commit547347d03618c90faff163f80f6520160f7c3741 (patch)
tree9ddee1886d6ddcea11ad20e37ae2f6233b840cce /plugins/New_GPG
parent3eb593cb61a7a7e2de574a1c54f538f025d90936 (diff)
new_gpg:
fix: avoid some deadlocks fix: crash workaround git-svn-id: http://svn.miranda-ng.org/main/trunk@15886 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/New_GPG')
-rwxr-xr-xplugins/New_GPG/src/messages.cpp32
1 files changed, 25 insertions, 7 deletions
diff --git a/plugins/New_GPG/src/messages.cpp b/plugins/New_GPG/src/messages.cpp
index 98476843cf..ccf1ca67bb 100755
--- a/plugins/New_GPG/src/messages.cpp
+++ b/plugins/New_GPG/src/messages.cpp
@@ -271,7 +271,12 @@ void RecvMsgSvc_func(MCONTACT hContact, std::wstring str, char *msg, DWORD, DWOR
str.append(toUTF16(tmp));
delete[] tmp;
f.close();
- boost::filesystem::remove(tszDecPath);
+ boost::system::error_code ec;
+ boost::filesystem::remove(tszDecPath, ec);
+ if(ec)
+ {
+ //TODO: handle error
+ }
}
}
if (str.empty())
@@ -608,15 +613,29 @@ void SendMsgSvc_func(MCONTACT hContact, char *msg, DWORD flags)
}
path += L"\\tmp\\";
path += file;
+ const int timeout = 5000, step = 100;
+ int count = 0;
{
fstream f(path.c_str(), std::ios::out);
while (!f.is_open()) {
- boost::this_thread::sleep(boost::posix_time::milliseconds(50));
+ boost::this_thread::sleep(boost::posix_time::milliseconds(step));
+ count += step;
+ if(count >= timeout)
+ {
+ db_set_b(hContact, szGPGModuleName, "GPGEncryption", 0); //disable encryption
+ setSrmmIcon(hContact);
+ setClistIcon(hContact);
+ debuglog << std::string(time_str() + ": info: failed to create temporary file for encryption, disabling encryption to avoid deadlock");
+ break;
+ }
f.open(path.c_str(), std::ios::out);
}
- std::string tmp = toUTF8(str);
- f.write(tmp.c_str(), tmp.size());
- f.close();
+ if(count < timeout)
+ {
+ std::string tmp = toUTF8(str);
+ f.write(tmp.c_str(), tmp.size());
+ f.close();
+ }
}
pxResult result;
{
@@ -676,8 +695,7 @@ void SendMsgSvc_func(MCONTACT hContact, char *msg, DWORD flags)
boost::filesystem::remove(path);
path.append(_T(".asc"));
wfstream f(path.c_str(), std::ios::in | std::ios::ate | std::ios::binary);
- const int timeout = 5000, step = 100;
- int count = 0;
+ count = 0;
while (!f.is_open()) {
boost::this_thread::sleep(boost::posix_time::milliseconds(step));
f.open(path.c_str(), std::ios::in | std::ios::ate | std::ios::binary);