Module: kamailio
Branch: master
Commit: 1bb1ba60992ffa35e8d36ed1dab98fdc36a2ea30
URL:
https://github.com/kamailio/kamailio/commit/1bb1ba60992ffa35e8d36ed1dab98fd…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)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/1bb1ba60992ffa35e8d36ed1dab98fd…
Patch:
https://github.com/kamailio/kamailio/commit/1bb1ba60992ffa35e8d36ed1dab98fd…
---
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);
+ }
}
}