[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sr-dev
Subject:    [sr-dev] git:master:1bb1ba60: core: dns cache - warnings on put for unlinked items
From:       Daniel-Constantin Mierla via sr-dev <sr-dev () lists ! kamailio ! org>
Date:       2023-09-28 7:05:33
Message-ID: E1qll5Z-0001Xj-2B () www ! kamailio ! org
[Download RAW message or body]

Module: kamailio
Branch: master
Commit: 1bb1ba60992ffa35e8d36ed1dab98fdc36a2ea30
URL: https://github.com/kamailio/kamailio/commit/1bb1ba60992ffa35e8d36ed1dab98fdc36a2ea30

Author: Daniel-Constantin Mierla <miconda@gmail.com>
Committer: Daniel-Constantin Mierla <miconda@gmail.com>
Date: 2023-09-28T09:03:50+02:00

core: dns cache - warnings on put for unlinked items

---

Modified: src/core/dns_cache.c

---

Diff:  https://github.com/kamailio/kamailio/commit/1bb1ba60992ffa35e8d36ed1dab98fdc36a2ea30.diff
Patch: https://github.com/kamailio/kamailio/commit/1bb1ba60992ffa35e8d36ed1dab98fdc36a2ea30.patch

---

diff --git a/src/core/dns_cache.c b/src/core/dns_cache.c
index 4ad478ba88d..7ff085b0300 100644
--- a/src/core/dns_cache.c
+++ b/src/core/dns_cache.c
@@ -164,9 +164,13 @@ inline static void dns_destroy_entry_shm_unsafe(struct dns_hash_entry *e)
 /* dec. the internal refcnt and if 0 deletes the entry */
 void dns_hash_put(struct dns_hash_entry *e)
 {
-	if(e && atomic_dec_and_test(&e->refcnt)) {
-		/* atomic_sub_long(dns_cache_total_used, e->total_size); */
-		dns_destroy_entry(e);
+	if(e != NULL) {
+		if(atomic_dec_and_test(&e->refcnt)) {
+			/* atomic_sub_long(dns_cache_total_used, e->total_size); */
+			dns_destroy_entry(e);
+		} else if(e->next == NULL && e->prev == NULL) {
+			LM_WARN("unlinked item %p\n", e);
+		}
 	}
 }
 
@@ -175,9 +179,13 @@ void dns_hash_put(struct dns_hash_entry *e)
  *  optimization) */
 void dns_hash_put_shm_unsafe(struct dns_hash_entry *e)
 {
-	if(e && atomic_dec_and_test(&e->refcnt)) {
-		/* atomic_sub_long(dns_cache_total_used, e->total_size); */
-		dns_destroy_entry_shm_unsafe(e);
+	if(e != NULL) {
+		if(atomic_dec_and_test(&e->refcnt)) {
+			/* atomic_sub_long(dns_cache_total_used, e->total_size); */
+			dns_destroy_entry_shm_unsafe(e);
+		} else if(e->next == NULL && e->prev == NULL) {
+			LM_WARN("unlinked item %p\n", e);
+		}
 	}
 }
 

_______________________________________________
Kamailio (SER) - Development Mailing List
To unsubscribe send an email to sr-dev-leave@lists.kamailio.org
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic