Module: kamailio
Branch: master
Commit: ff3cf17ff3566cb08cb0a6b9f7f7d893cd908956
URL: https://github.com/kamailio/kamailio/commit/ff3cf17ff3566cb08cb0a6b9f7f7d89…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2017-05-02T10:37:41+02:00
core, sctp: check if IP_FREEBIND is defined
- not all os-es have it
---
Modified: src/core/tcp_main.c
Modified: src/core/udp_server.c
Modified: src/modules/sctp/sctp_server.c
---
Diff: https://github.com/kamailio/kamailio/commit/ff3cf17ff3566cb08cb0a6b9f7f7d89…
Patch: https://github.com/kamailio/kamailio/commit/ff3cf17ff3566cb08cb0a6b9f7f7d89…
---
diff --git a/src/core/tcp_main.c b/src/core/tcp_main.c
index b9af4e8..2b08967 100644
--- a/src/core/tcp_main.c
+++ b/src/core/tcp_main.c
@@ -2783,12 +2783,16 @@ int tcp_init(struct socket_info* sock_info)
}
}
- /* Allow bind to non local address. Required when daemon started before network initialized */
+#if defined(IP_FREEBIND)
+ /* allow bind to non local address.
+ * useful when daemon started before network initialized */
if (setsockopt(sock_info->socket, IPPROTO_IP, IP_FREEBIND,
(void*)&optval, sizeof(optval)) ==-1) {
- LM_WARN("setsockopt freebind: %s\n", strerror(errno));
+ LM_WARN("setsockopt freebind failed: %s\n", strerror(errno));
/* continue since this is not critical */
}
+#endif
+
#ifdef HAVE_TCP_DEFER_ACCEPT
/* linux only */
if ((optval=cfg_get(tcp, tcp_cfg, defer_accept))){
diff --git a/src/core/udp_server.c b/src/core/udp_server.c
index 96ba8eb..2641fae 100644
--- a/src/core/udp_server.c
+++ b/src/core/udp_server.c
@@ -339,14 +339,16 @@ int udp_init(struct socket_info* sock_info)
}
#endif
- /* Allow bind to non local address. Required when daemon started before network initialized */
+#if defined(IP_FREEBIND)
+ /* allow bind to non local address.
+ * useful when daemon started before network initialized */
optval = 1;
if (setsockopt(sock_info->socket, IPPROTO_IP, IP_FREEBIND,
(void*)&optval, sizeof(optval)) ==-1) {
- LM_WARN("setsockopt freebind: %s\n", strerror(errno));
+ LM_WARN("setsockopt freebind failed: %s\n", strerror(errno));
/* continue since this is not critical */
}
-
+#endif
#ifdef USE_MCAST
if ((sock_info->flags & SI_IS_MCAST)
&& (setup_mcast_rcvr(sock_info->socket, addr, sock_info->mcast.s)<0)){
diff --git a/src/modules/sctp/sctp_server.c b/src/modules/sctp/sctp_server.c
index 686139c..5d5371a 100644
--- a/src/modules/sctp/sctp_server.c
+++ b/src/modules/sctp/sctp_server.c
@@ -468,14 +468,17 @@ static int sctp_init_sock_opt_common(int s, int af)
/* continue since this is not critical */
}
}
-
- /* Allow bind to non local address. Required when daemon started before network initialized */
+
+#if defined(IP_FREEBIND)
+ /* allow bind to non local address.
+ * useful when daemon started before network initialized */
optval = 1;
if (setsockopt(s, IPPROTO_IP, IP_FREEBIND,
(void*)&optval, sizeof(optval)) ==-1) {
- LM_WARN("sctp_init_sock_opt_common: setsockopt freebind %s\n", strerror(errno));
+ LM_WARN("setsockopt freebind failed: %s\n", strerror(errno));
/* continue since this is not critical */
}
+#endif
/* set receive buffer: SO_RCVBUF*/
if (cfg_get(sctp, sctp_cfg, so_rcvbuf)){
@@ -487,7 +490,7 @@ static int sctp_init_sock_opt_common(int s, int af)
/* continue, non-critical */
}
}
-
+
/* set send buffer: SO_SNDBUF */
if (cfg_get(sctp, sctp_cfg, so_sndbuf)){
optval=cfg_get(sctp, sctp_cfg, so_sndbuf);
Hi,
i'm investigating a possible memory leak in registrar module, namely in xavp_rcd_helper function.
noticed an increase in shared memory allocated by core, removing the modparam("registrar", "xavp_rcd", "ulrcd") seems to fix this.
[root@dev-01 kamailio]# kamcmd mod.stats core shm
Module: core
{
xavp_new_value(94): 35704
.....
}
[root@dev-01 kamailio]# kamcmd mod.stats core shm
Module: core
{
xavp_new_value(94): 164064
....
}
only one client registering every 60 sec.
not sure if it keeps accumulating values in the xavp or if its leaking.
however, a doubt came across. the lookup function is supposed to fill the xavp if configured, but the value seems to be related to the current process and afaik xavp are allocated in shared memory making it available to all processes. now, if two requests arrive at the same time and both do a lookup on the registrar, the xavp will potentially have the wrong value for one of the requests.
what am i missing here ?
Thanks