Module: kamailio
Branch: master
Commit: 81e9c4f965dcedccdc73f88c6b8f0c2ff09598c8
URL: https://github.com/kamailio/kamailio/commit/81e9c4f965dcedccdc73f88c6b8f0c2…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2025-06-27T13:41:29+02:00
core: log file and line for dns hash remove entry with high refcnt
---
Modified: src/core/dns_cache.c
---
Diff: https://github.com/kamailio/kamailio/commit/81e9c4f965dcedccdc73f88c6b8f0c2…
Patch: https://github.com/kamailio/kamailio/commit/81e9c4f965dcedccdc73f88c6b8f0c2…
---
diff --git a/src/core/dns_cache.c b/src/core/dns_cache.c
index 9f6e47781f2..fbc5e83f27c 100644
--- a/src/core/dns_cache.c
+++ b/src/core/dns_cache.c
@@ -484,18 +484,24 @@ int init_dns_cache_stats(int iproc_num)
/* must be called with the DNS_LOCK hold
* removes an entry from the hash, dec. its refcnt and if not referenced
* anymore deletes it */
-inline static void _dns_hash_remove(struct dns_hash_entry *e)
+inline static void _dns_hash_remove_entry(
+ struct dns_hash_entry *e, char *fpath, unsigned int line)
{
clist_rm(e, next, prev);
e->next = e->prev = 0;
- debug_lu_lst("_dns_hash_remove: pre rm:", &e->last_used_lst);
+ debug_lu_lst("dns hash remove: pre rm:", &e->last_used_lst);
clist_rm(&e->last_used_lst, next, prev);
- debug_lu_lst("_dns_hash_remove: post rm:", &e->last_used_lst);
+ debug_lu_lst("dns hash remove: post rm:", &e->last_used_lst);
e->last_used_lst.next = e->last_used_lst.prev = 0;
*dns_cache_mem_used -= e->total_size;
+ if(atomic_get_int(&e->refcnt) > 1) {
+ LM_INFO("item %p with high refcnt %d (%s:%u)\n", e,
+ atomic_get_int(&e->refcnt), fpath, line);
+ }
dns_hash_put(e);
}
+#define _dns_hash_remove(e) _dns_hash_remove_entry(e, __FILE__, __LINE__)
/* non locking version (the dns hash must _be_ locked externally)
* returns 0 when not found, or the entry on success (an entry with a
2954456878 created an issue (kamailio/kamailio#4300)
loadmodule "nghttp2.so"
modparam("nghttp2", "listen_addr", "0.0.0.0")
modparam("nghttp2", "listen_port", "8363")
event_route[nghttp2:request] {
xinfo("request: $nghttp2(method) - url: $nghttp2(path) - data: [$nghttp2(data)]\n");
nghttp2_reply("200","<html><body>OK</body></html>");
}
curl -H "Content-Type: application/json" -X POST -d '{"test":"data"}' "http://127.0.0.1:8363/"
curl: (56) Recv failure: Connection reset by peer
When using curl request, the message "Recv failure" appears. What is wrong with the settings?
--
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/4300
You are receiving this because you are subscribed to this thread.
Message ID: <kamailio/kamailio/issues/4300(a)github.com>
### Description
After carrying out some load tests using the `Websocket` module, I noticed that sometimes the `websocket:closed` event is not triggered.
This problem seems to be particularly noticeable when the load is high and simultaneous. Example: 1000 records simultaneously.
In the tests carried out, I realized that the number of times the event is not triggered is small, in the order of [1-10]/1000.
I check that when I do a `ws.dump` I don't have any active connections, and I confirm that they are all effectively cleaned (`netstat -ano | grep 8061`).
However, the event is not triggered for some connections.
I can see this in the logs, and also when i display the content of an hash table, i'm dropping key inside `websocket:closed` event.
### Troubleshooting
The troubleshooting was simplistic, i.e. I ran the same test n times, and validated that the event was triggered for all connections, the number of `ws` connections listed by `Kamailio`, and the open connections.
#### Reproduction
To reproduce, we can use any mechanism that emulates the use of the `Websocket` module.
For example, I used the `sipexer` tool to create a `wss` connection with `Kamailio`, forcing simultaneous registrations.
Example command: `sipexer -cb -mt register -ex 60 -au <user> -ap <pass> -fuser example -fd mydomain -wso https://10.0.0.12:10000 -ruri sip:kamailio -su wss://kamailio:8061`
Kamailio TLS listener:
`listen=tls:10.0.0.12:8061 advertise PUBLIC_IP`
Websocket module:
```
loadmodule "websocket.so"
tcp_accept_no_cl=yes
```
```
event_route[websocket:closed] {
xlog("L_NOTICE", "WebSocket connection closed $proto:$si:$sp\n");
<I also delete where a htable key>
}
```
#### Debugging Data
```
[root@ ~]$ prcmd ws.dump
{
connections: {
}
info: {
wscounter: 0
truncated: no
}
}
[root@ ~]$ netstat -ano | grep 8061
tcp 0 0 10.0.0.12:8061 0.0.0.0:* LISTEN off (0.00/0/0)
[root ~]$ prcmd htable.dump wsauth | grep "name" | wc -l
3
[root ~]$ cat /var/log/kamailio.log | grep "WebSocket connection closed" | wc -l
997
[root ~]$ cat /var/log/proxy-registrar/proxy-registrar.log | grep "ERR" | grep "WAR" | wc -l
0
```
#### Log Messages
Nothing relevant.
#### SIP Traffic
Nothing relevant here, the SIP Flow is OK.
### Additional Information
```
version: kamailio 5.6.4 (x86_64/linux) a004cf-dirty
flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLOCKLIST, HAVE_RESOLV_RES
ADAPTIVE_WAIT_LOOPS 1024, MAX_RECV_BUFFER_SIZE 262144, MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: a004cf -dirty
compiled on 23:17:27 Jun 7 2024 with gcc 4.8.5
```
* **Operating System**:
```
CentOS Linux release 7.9.2009 (Core)
```
--
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/3950
You are receiving this because you are subscribed to this thread.
Message ID: <kamailio/kamailio/issues/3950(a)github.com>