diff options
author | George Hazan <george.hazan@gmail.com> | 2013-08-06 18:52:28 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-08-06 18:52:28 +0000 |
commit | 90fc3521557ae33352dcc7baa87828b6bb0ca2b9 (patch) | |
tree | 8e0891cca3e94e348ee32e81d54d6da9d5b151d7 /plugins/SeenPlugin/src/utils.cpp | |
parent | 7ebc990573da8a08c58c1092ed126357c44804f5 (diff) |
fix for very rare crash on slow machines
git-svn-id: http://svn.miranda-ng.org/main/trunk@5604 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/SeenPlugin/src/utils.cpp')
-rw-r--r-- | plugins/SeenPlugin/src/utils.cpp | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/plugins/SeenPlugin/src/utils.cpp b/plugins/SeenPlugin/src/utils.cpp index 66fe989393..c7e0705a7d 100644 --- a/plugins/SeenPlugin/src/utils.cpp +++ b/plugins/SeenPlugin/src/utils.cpp @@ -516,17 +516,6 @@ void myPlaySound(HANDLE hcontact, WORD newStatus, WORD oldStatus) }
//will add hContact to queue and will return position;
-static logthread_info* addContactToQueue(HANDLE hContact)
-{
- if (!hContact)
- return NULL;
-
- logthread_info *p = (logthread_info*)mir_calloc(sizeof(logthread_info));
- p->hContact = hContact;
- arContacts.insert(p);
- return p;
-}
-
static void waitThread(void *param)
{
logthread_info* infoParam = (logthread_info*)param;
@@ -547,8 +536,10 @@ static void waitThread(void *param) db_set_w(infoParam->hContact,S_MOD,"StatusTriger",infoParam->currStatus);
}
}
-
- arContacts.remove(infoParam);
+ {
+ mir_cslock lck(csContacts);
+ arContacts.remove(infoParam);
+ }
mir_free(infoParam);
}
@@ -626,13 +617,16 @@ int UpdateValues(WPARAM wparam,LPARAM lparam) db_set_b(hContact, S_MOD, "Offline", 0);
}
}
- else if (IsWatchedProtocol(cws->szModule)) {
+ else if (hContact && IsWatchedProtocol(cws->szModule)) {
//here we will come when <User>/<module>/Status is changed or it is idle event and if <module> is watched
if ( CallProtoService(cws->szModule,PS_GETSTATUS,0,0) > ID_STATUS_OFFLINE){
+ mir_cslock lck(csContacts);
logthread_info *p = arContacts.find((logthread_info*)&hContact);
if (p == NULL) {
- p = addContactToQueue(hContact);
+ p = (logthread_info*)mir_calloc(sizeof(logthread_info));
+ p->hContact = hContact;
strncpy(p->sProtoName, cws->szModule, MAXMODULELABELLENGTH);
+ arContacts.insert(p);
mir_forkthread(waitThread, p);
}
p->currStatus = isIdleEvent ? db_get_w(hContact, cws->szModule, "Status", ID_STATUS_OFFLINE) : cws->value.wVal;
|