diff options
author | Gluzskiy Alexandr <sss123next@list.ru> | 2010-08-27 00:00:01 +0300 |
---|---|---|
committer | Gluzskiy Alexandr <sss123next@list.ru> | 2010-08-27 00:00:01 +0300 |
commit | 26f425f0153de537bc676c9c38a68ef3edd882c5 (patch) | |
tree | 93f1177bfbc5f6e29bc4de2a64a476edf4264052 /utilities.cpp | |
parent | b06316ffd29888f749d927577e15ced4945cc5d0 (diff) |
using threads, gpg execution timeout, fixed high cpu usage when waiting gpg process
Diffstat (limited to 'utilities.cpp')
-rw-r--r-- | utilities.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/utilities.cpp b/utilities.cpp index 7d0b241..b07b7ba 100644 --- a/utilities.cpp +++ b/utilities.cpp @@ -410,10 +410,23 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, HXML node, void *pU cmd += _T(" --batch --yes -a -s \""); cmd += path_out; cmd += _T("\" ");
- if(pxExecute(&cmd, "", &out, &code) == pxNotFound)
+ gpg_execution_params params;
+ pxResult result;
+ params.cmd = &cmd;
+ params.useless = "";
+ 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)
{
+ TerminateThread(gpg_thread, 0);
+ MessageBox(0, _T("GPG execution timed out, aborted"), _T(""), MB_OK);
+ }
+ if(result == pxNotFound)
+ { MessageBox(0, _T("Set path to gpg.exe first!"), _T("Warning"), MB_OK);
- } + }
DeleteFile(path_out.c_str()); path_out += _T(".asc"); f.open(path_out.c_str(), std::ios::in); |