diff options
author | George Hazan <george.hazan@gmail.com> | 2013-03-18 09:35:26 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-03-18 09:35:26 +0000 |
commit | 5b365d71c4ae382d93c5ee90c66604e41ab4b1fb (patch) | |
tree | 78124acedd7633b9a7a8fe39d39c93ff3647ac94 /plugins/CryptoPP | |
parent | 3f88620733ada264505ffa7b527145481af7d2ef (diff) |
- strange endless thread removed from CryptoPP;
- cleanup procedure established;
- version bump
git-svn-id: http://svn.miranda-ng.org/main/trunk@4087 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/CryptoPP')
-rw-r--r-- | plugins/CryptoPP/src/commonheaders.h | 1 | ||||
-rw-r--r-- | plugins/CryptoPP/src/cpp_cntx.cpp | 104 | ||||
-rw-r--r-- | plugins/CryptoPP/src/cpp_rsam.cpp | 9 |
3 files changed, 21 insertions, 93 deletions
diff --git a/plugins/CryptoPP/src/commonheaders.h b/plugins/CryptoPP/src/commonheaders.h index d1829f7836..1e16f4e6d8 100644 --- a/plugins/CryptoPP/src/commonheaders.h +++ b/plugins/CryptoPP/src/commonheaders.h @@ -83,7 +83,6 @@ extern HANDLE hPGPPRIV; extern HANDLE hRSA4096;
extern CRITICAL_SECTION localQueueMutex;
-extern CRITICAL_SECTION localContextMutex;
void ExtractFile(char*,int,int);
size_t rtrim(LPCSTR);
diff --git a/plugins/CryptoPP/src/cpp_cntx.cpp b/plugins/CryptoPP/src/cpp_cntx.cpp index 72c35dcc96..c4d2c46338 100644 --- a/plugins/CryptoPP/src/cpp_cntx.cpp +++ b/plugins/CryptoPP/src/cpp_cntx.cpp @@ -1,68 +1,26 @@ #include "commonheaders.h"
-
-list<pCNTX> CL; // CL.size() CL.empty()
-
-HANDLE thread_timeout = 0;
-
-unsigned __stdcall sttTimeoutThread(LPVOID);
-
-
// get context data on context id
pCNTX get_context_on_id(HANDLE context) {
-
- if ( !thread_timeout ) {
- unsigned int tID;
- thread_timeout = (HANDLE) _beginthreadex(NULL, 0, sttTimeoutThread, NULL, 0, &tID);
- }
-
- if ( context ) {
- pCNTX cntx = (pCNTX) context;
- if ( cntx->header == HEADER && cntx->footer == FOOTER )
- return cntx;
-#if defined(_DEBUG) || defined(NETLIB_LOG)
- else
- Sent_NetLog("get_context_on_id: corrupted context %08X", cntx);
-#endif
- }
- return NULL;
-}
-
-/*
-pCNTX get_context_on_id(HANDLE context) {
- return get_context_on_id((int)context);
+ if ( context ) {
+ pCNTX cntx = (pCNTX) context;
+ if ( cntx->header == HEADER && cntx->footer == FOOTER )
+ return cntx;
+
+ #if defined(_DEBUG) || defined(NETLIB_LOG)
+ Sent_NetLog("get_context_on_id: corrupted context %08X", cntx);
+ #endif
+ }
+ return NULL;
}
-*/
// create context, return context id
HANDLE __cdecl cpp_create_context(int mode) {
-
- list<pCNTX>::iterator i;
- pCNTX cntx = NULL;
-
- EnterCriticalSection(&localContextMutex);
-
- if ( !CL.empty() ) {
- for(i=CL.begin(); i!=CL.end(); ++i) { // ищем пустой
- if ( (*i)->header==EMPTYH && (*i)->footer==EMPTYH ) {
- cntx = (pCNTX) *i;
- break;
- }
- }
- }
-
- if ( !cntx ) { // не нашли - создаем новый
- cntx = (pCNTX) malloc(sizeof(CNTX));
- CL.push_back(cntx); // добавили в конец списка
- }
-
+ pCNTX cntx = (pCNTX) malloc(sizeof(CNTX));
memset(cntx,0,sizeof(CNTX)); // очищаем выделенный блок
cntx->header = HEADER;
cntx->footer = FOOTER;
cntx->mode = mode;
-
- LeaveCriticalSection(&localContextMutex);
-
return (HANDLE)cntx;
}
@@ -72,7 +30,8 @@ void __cdecl cpp_delete_context(HANDLE context) { pCNTX tmp = get_context_on_id(context);
if (tmp) { // помечаем на удаление
- tmp->deleted = gettime()+10; // будет удален через 10 секунд
+ cpp_free_keys(tmp);
+ free(tmp);
}
}
@@ -144,41 +103,4 @@ void cpp_free_keys(pCNTX ptr) { }
}
-
-// search not established RSA/AES contexts && clear deleted contexts
-unsigned __stdcall sttTimeoutThread( LPVOID ) {
-
- list<pCNTX>::iterator i;
- while(1) {
- Sleep( 1000 ); // раз в секунду
- if ( CL.empty() ) continue;
- u_int time = gettime();
- // пробегаем все контексты
- EnterCriticalSection(&localContextMutex);
- for(i=CL.begin(); i!=CL.end(); ++i) {
- pCNTX tmp = *i;
- if ( tmp->header!=HEADER || tmp->footer!=FOOTER ) continue;
- // пропускаем приватные ключи
- if ( tmp->mode&MODE_PRIV_KEY ) continue;
- else
- if ( tmp->deleted && tmp->deleted < time ) {
- // удалить помеченный для удаления контекст
- cpp_free_keys(tmp);
- tmp->deleted = 0;
- tmp->header = tmp->footer = EMPTYH;
- }
- else
- if ( tmp->mode&MODE_RSA && tmp->pdata ) {
- // проверяем не протухло ли соединение
- pRSADATA p = (pRSADATA) tmp->pdata;
- if ( p->time && p->time < time ) {
- rsa_timeout((HANDLE)tmp,p);
- }
- }
- } // for
- LeaveCriticalSection(&localContextMutex);
- } //while
-}
-
-
// EOF
diff --git a/plugins/CryptoPP/src/cpp_rsam.cpp b/plugins/CryptoPP/src/cpp_rsam.cpp index 3cdb391660..0fd1e9de7f 100644 --- a/plugins/CryptoPP/src/cpp_rsam.cpp +++ b/plugins/CryptoPP/src/cpp_rsam.cpp @@ -68,6 +68,14 @@ int __cdecl rsa_done(void) { #if defined(_DEBUG) || defined(NETLIB_LOG)
Sent_NetLog("rsa_done");
#endif
+ if ( hRSA4096 ) {
+ pCNTX tmp = (pCNTX) hRSA4096;
+ pRSAPRIV p = (pRSAPRIV)tmp->pdata;
+ delete p;
+ tmp->pdata = 0;
+ cpp_delete_context(hRSA4096);
+ }
+
return 1;
}
@@ -858,7 +866,6 @@ void rsa_free( pCNTX ptr ) { if ( p && p->event ) {
p->thread_exit = 2; // отпускаем поток в свободное плавание
SetEvent( p->event );
- rsa_alloc(ptr);
}
}
|