This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Hoernchen gerrit-no-reply at lists.osmocom.orgHoernchen has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-mgw/+/25424 )
Change subject: globally lock the portrange when trying to grab a port, fucks performance
......................................................................
globally lock the portrange when trying to grab a port, fucks performance
Change-Id: I78ae737b829bb428372f34db7d5bc601b5088b78
---
M include/osmocom/mgcp/mgcp.h
M src/libosmo-mgcp/mgcp_protocol.c
2 files changed, 7 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/24/25424/1
diff --git a/include/osmocom/mgcp/mgcp.h b/include/osmocom/mgcp/mgcp.h
index b3f2eb5..228b0b3 100644
--- a/include/osmocom/mgcp/mgcp.h
+++ b/include/osmocom/mgcp/mgcp.h
@@ -34,6 +34,7 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#include <pthread.h>
#include "mgcp_ratectr.h"
@@ -92,6 +93,7 @@
* This holds information on how to allocate ports
*/
struct mgcp_port_range {
+ pthread_mutex_t lock;
/* addr or NULL to fall-back to default */
char *bind_addr_v4;
char *bind_addr_v6;
diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c
index a8e1813..1b34087 100644
--- a/src/libosmo-mgcp/mgcp_protocol.c
+++ b/src/libosmo-mgcp/mgcp_protocol.c
@@ -28,6 +28,7 @@
#include <limits.h>
#include <unistd.h>
#include <errno.h>
+#include <pthread.h>
#include <osmocom/core/msgb.h>
#include <osmocom/core/talloc.h>
@@ -487,6 +488,7 @@
range = &endp->cfg->net_ports;
+ pthread_mutex_lock(&range->lock);
/* attempt to find a port */
tries = (range->range_end - range->range_start) / 2;
for (i = 0; i < tries; ++i) {
@@ -499,11 +501,12 @@
range->last_port += 2;
if (rc == 0) {
+ pthread_mutex_unlock(&range->lock);
return 0;
}
}
-
+ pthread_mutex_unlock(&range->lock);
LOGPENDP(endp, DLMGCP, LOGL_ERROR,
"Allocating a RTP/RTCP port failed %u times.\n",
tries);
@@ -1615,6 +1618,7 @@
osmo_strlcpy(cfg->domain, "mgw", sizeof(cfg->domain));
+ cfg->net_ports.lock = PTHREAD_MUTEX_INITIALIZER;
cfg->net_ports.range_start = RTP_PORT_DEFAULT_RANGE_START;
cfg->net_ports.range_end = RTP_PORT_DEFAULT_RANGE_END;
cfg->net_ports.last_port = cfg->net_ports.range_start;
--
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/25424
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: I78ae737b829bb428372f34db7d5bc601b5088b78
Gerrit-Change-Number: 25424
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen <ewild at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210909/0b52ef0f/attachment.htm>