]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #2849 in SNORT/snort3 from ~DIPANDIT/snort3:lru_dead_lock to master
authorBhargava Jandhyala (bjandhya) <bjandhya@cisco.com>
Mon, 19 Apr 2021 12:22:13 +0000 (12:22 +0000)
committerBhargava Jandhyala (bjandhya) <bjandhya@cisco.com>
Mon, 19 Apr 2021 12:22:13 +0000 (12:22 +0000)
Squashed commit of the following:

commit 57c873106b055daf409b5a712a98f67d642c8d1a
Author: Dipto Pandit (dipandit) <dipandit@cisco.com>
Date:   Mon Apr 19 02:43:27 2021 -0400

    hash: prepond object creation in LRU cache find_else_create

src/hash/lru_cache_shared.h

index 60254e8e4e8a39af1f42e1b4e4c7ca141432bb69..ac7fbcc59ea30e414385de9875f471b3cd6312a2 100644 (file)
@@ -243,6 +243,7 @@ find_else_create(const Key& key, bool* new_data)
     // return the data pointer (below), or else, some other thread might
     // delete it before we got a chance to return it.
     Purgatory tmp_data;
+    Data data = Data(new Value);
 
     std::lock_guard<std::mutex> cache_lock(cache_mutex);
 
@@ -258,7 +259,6 @@ find_else_create(const Key& key, bool* new_data)
     stats.adds++;
     if ( new_data )
         *new_data = true;
-    Data data = Data(new Value);
 
     //  Add key/data pair to front of list.
     list.emplace_front(std::make_pair(key, data));