From: Bhargava Jandhyala (bjandhya) Date: Mon, 19 Apr 2021 12:22:13 +0000 (+0000) Subject: Merge pull request #2849 in SNORT/snort3 from ~DIPANDIT/snort3:lru_dead_lock to master X-Git-Tag: 3.1.4.0~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=49b8d0dd8b6328bbf849e00ed673f3b262defb52;p=thirdparty%2Fsnort3.git Merge pull request #2849 in SNORT/snort3 from ~DIPANDIT/snort3:lru_dead_lock to master Squashed commit of the following: commit 57c873106b055daf409b5a712a98f67d642c8d1a Author: Dipto Pandit (dipandit) Date: Mon Apr 19 02:43:27 2021 -0400 hash: prepond object creation in LRU cache find_else_create --- diff --git a/src/hash/lru_cache_shared.h b/src/hash/lru_cache_shared.h index 60254e8e4..ac7fbcc59 100644 --- a/src/hash/lru_cache_shared.h +++ b/src/hash/lru_cache_shared.h @@ -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 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));