[sr-dev] git:master:06f933ad: usrloc: re-use TCP connections for keepalive
Daniel-Constantin Mierla
miconda at gmail.com
Wed Aug 17 10:33:55 CEST 2022
Module: kamailio
Branch: master
Commit: 06f933ad17aac3a3f0f81cf0e0ab04f38cf60993
URL: https://github.com/kamailio/kamailio/commit/06f933ad17aac3a3f0f81cf0e0ab04f38cf60993
Author: Andy Brezinsky <andy.brezinsky at mitel.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2022-08-17T10:33:50+02:00
usrloc: re-use TCP connections for keepalive
- Fixes GH #3178. Sets TCP connection id for keepalive based on the value in the database
If unset, tcpconn_id will remain 0 and keepalives will work the same as they do today
- Update documentation to clarify when it will use received vs AOR for keepalive
---
Modified: src/modules/usrloc/dlist.c
Modified: src/modules/usrloc/doc/usrloc_admin.xml
Modified: src/modules/usrloc/ul_keepalive.c
---
Diff: https://github.com/kamailio/kamailio/commit/06f933ad17aac3a3f0f81cf0e0ab04f38cf60993.diff
Patch: https://github.com/kamailio/kamailio/commit/06f933ad17aac3a3f0f81cf0e0ab04f38cf60993.patch
---
diff --git a/src/modules/usrloc/dlist.c b/src/modules/usrloc/dlist.c
index 252bb8bde07..c0c7cb0009f 100644
--- a/src/modules/usrloc/dlist.c
+++ b/src/modules/usrloc/dlist.c
@@ -114,6 +114,7 @@ int ul_ka_db_records(int partidx)
keys2[5] = &ul_ruid_col;
keys2[6] = &ul_user_col;
keys2[7] = &ul_domain_col;
+ keys2[8] = &ul_con_id_col;
/* where fields */
keys1[0] = &ul_expires_col;
@@ -256,6 +257,9 @@ int ul_ka_db_records(int partidx)
ur.aorhash = ul_get_aorhash(&ur.aor);
ur.contacts = &uc;
+ /* tcpconn_id */
+ uc.tcpconn_id = VAL_INT(ROW_VALUES(row)+8);
+
ul_ka_urecord(&ur);
} /* row cycle */
diff --git a/src/modules/usrloc/doc/usrloc_admin.xml b/src/modules/usrloc/doc/usrloc_admin.xml
index 66dae449130..f2d2001689c 100644
--- a/src/modules/usrloc/doc/usrloc_admin.xml
+++ b/src/modules/usrloc/doc/usrloc_admin.xml
@@ -1317,11 +1317,17 @@ modparam("usrloc", "version_table", 0)
contact records stored in memory.
</para>
<para>
- Note: it is recommeder to set 'timer_procs' parameter in order to have
+ Note: it is recommended to set 'timer_procs' parameter in order to have
dedicated timer processes for usrloc module and off-load the keepalive
sending process from the core timers.
</para>
<para>
+ Note: Keepalives will be sent to the IP and port using the transport
+ defined in the âreceivedâ column. If not set, then keepalives will be sent
+ to the AOR using UDP as a default transport. If available, the TCP
+ connection will be re-used for WS, TCP and TLS.
+ </para>
+ <para>
Default value is <quote>0 (keepalive disabled)</quote>.
</para>
<example>
@@ -1780,4 +1786,3 @@ modparam("usrloc", "db_clean_tcp", 1)
</chapter>
-
diff --git a/src/modules/usrloc/ul_keepalive.c b/src/modules/usrloc/ul_keepalive.c
index 8808725849f..ffe37fdc738 100644
--- a/src/modules/usrloc/ul_keepalive.c
+++ b/src/modules/usrloc/ul_keepalive.c
@@ -200,6 +200,7 @@ int ul_ka_urecord(urecord_t *ur)
}
idst.proto = dproto;
idst.send_sock = ssock;
+ idst.id = uc->tcpconn_id;
if(ssock->useinfo.name.len > 0) {
if (ssock->useinfo.address.af == AF_INET6) {
@@ -270,19 +271,16 @@ static int ul_ka_send(str *kamsg, dest_info_t *kadst)
#ifdef USE_TCP
else if(kadst->proto == PROTO_WS || kadst->proto == PROTO_WSS) {
/*ws-wss*/
- kadst->id=0;
return wss_send(kadst, kamsg->s, kamsg->len);
}
else if(kadst->proto == PROTO_TCP) {
/*tcp*/
- kadst->id=0;
return tcp_send(kadst, 0, kamsg->s, kamsg->len);
}
#endif
#ifdef USE_TLS
else if(kadst->proto == PROTO_TLS) {
/*tls*/
- kadst->id=0;
return tcp_send(kadst, 0, kamsg->s, kamsg->len);
}
#endif
More information about the sr-dev
mailing list