diff options
author | George Hazan <ghazan@miranda.im> | 2018-04-13 19:28:30 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-04-13 19:28:30 +0300 |
commit | 81dd07b3ae0c7f31da0c6766b8b325e2601e4195 (patch) | |
tree | e9291a9b5bd6e0e307c93332a5dc78985030b8c7 /plugins/AVS/src | |
parent | 803b5a53f145e08a1c2a5a730b2f0a796a83a7a2 (diff) |
fix for deadlock in AVS
Diffstat (limited to 'plugins/AVS/src')
-rw-r--r-- | plugins/AVS/src/cache.cpp | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/plugins/AVS/src/cache.cpp b/plugins/AVS/src/cache.cpp index bb04abaf2d..6b4ac7417e 100644 --- a/plugins/AVS/src/cache.cpp +++ b/plugins/AVS/src/cache.cpp @@ -75,20 +75,23 @@ CacheNode* FindAvatarInCache(MCONTACT hContact, bool add, bool findAny) if (szProto == nullptr || !db_get_b(NULL, AVS_MODULE, szProto, 1))
return nullptr;
- mir_cslock lck(cachecs);
- CacheNode *cc = arCache.find((CacheNode*)&hContact);
- if (cc) {
- cc->t_lastAccess = time(nullptr);
- return (cc->loaded || findAny) ? cc : nullptr;
- }
+ CacheNode *cc;
+ {
+ mir_cslock lck(cachecs);
+ cc = arCache.find((CacheNode*)&hContact);
+ if (cc) {
+ cc->t_lastAccess = time(nullptr);
+ return (cc->loaded || findAny) ? cc : nullptr;
+ }
- // not found
- if (!add)
- return nullptr;
+ // not found
+ if (!add)
+ return nullptr;
- cc = new CacheNode();
- cc->hContact = hContact;
- arCache.insert(cc);
+ cc = new CacheNode();
+ cc->hContact = hContact;
+ arCache.insert(cc);
+ }
switch (CreateAvatarInCache(hContact, cc, nullptr)) {
case -2: // no avatar data in settings, retrieve
|