From: Wouter Wijngaards Date: Fri, 2 Feb 2018 10:52:44 +0000 (+0000) Subject: - lock subnet new item before insertion to please checklocks, X-Git-Tag: release-1.7.0rc1~64 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=632ea0d02e31e61a89318f7e25420c622cdc6fbe;p=thirdparty%2Funbound.git - lock subnet new item before insertion to please checklocks, no modification of critical regions outside of lock region. git-svn-id: file:///svn/unbound/trunk@4497 be551aaa-1e26-0410-a405-d3ace91eadb9 --- diff --git a/doc/Changelog b/doc/Changelog index 11aec5b35..77f6e2036 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -2,6 +2,8 @@ - Fix unfreed locks in log and arc4random at exit of unbound. - unit test with valgrind - Fix lock race condition in dns cache dname synthesis. + - lock subnet new item before insertion to please checklocks, + no modification of critical regions outside of lock region. 1 February 2018: Wouter - fix unaligned structure making a false positive in checklock diff --git a/edns-subnet/subnetmod.c b/edns-subnet/subnetmod.c index 4b8a4b211..bea59ebf5 100644 --- a/edns-subnet/subnetmod.c +++ b/edns-subnet/subnetmod.c @@ -339,6 +339,7 @@ update_cache(struct module_qstate *qstate, int id) return; } lru_entry = &mrep_entry->entry; + lock_rw_wrlock(&lru_entry->lock); lru_entry->data = calloc(1, sizeof(struct subnet_msg_cache_data)); if (!lru_entry->data) { @@ -374,6 +375,7 @@ update_cache(struct module_qstate *qstate, int id) if (acquired_lock) { lock_rw_unlock(&lru_entry->lock); } else { + lock_rw_unlock(&lru_entry->lock); slabhash_insert(subnet_msg_cache, h, lru_entry, lru_entry->data, NULL); }