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/.
dexter gerrit-no-reply at lists.osmocom.orgdexter has uploaded this change for review. ( https://gerrit.osmocom.org/9259
Change subject: protocol: Try whole port range on port allocation
......................................................................
protocol: Try whole port range on port allocation
The function allocate_port tryes at least 200 different ports when
a new port is allocated. Since after every allocation the port
number is incremented the allocation should be able to allocate
a port with the first attempt. However, the number 200 is an
arbitrary number and it will not cover the whole port range in
most cases.
- Make sure that in the worst case at each port in the range
is tryed once, not only the next 200
Change-Id: Ic47f09869eaddd4aea817bb2517362883d65d029
Related: OS#2825
---
M src/libosmo-mgcp/mgcp_protocol.c
1 file changed, 8 insertions(+), 5 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/59/9259/1
diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c
index ea86672..77196b9 100644
--- a/src/libosmo-mgcp/mgcp_protocol.c
+++ b/src/libosmo-mgcp/mgcp_protocol.c
@@ -356,13 +356,15 @@
/* Try to find a free port by attempting to bind on it. Also handle the
* counter that points on the next free port. Since we have a pointer
- * to the next free port, binding should work on the first attempt,
- * nevertheless, try at least the next 200 ports before giving up */
+ * to the next free port, binding should in work on the first attempt in
+ * general. In case of failure the next port is tryed until the whole port
+ * range is tryed once. */
static int allocate_port(struct mgcp_endpoint *endp, struct mgcp_conn_rtp *conn)
{
int i;
struct mgcp_rtp_end *end;
struct mgcp_port_range *range;
+ unsigned int trys;
OSMO_ASSERT(conn);
end = &conn->end;
@@ -371,7 +373,8 @@
range = &endp->cfg->net_ports;
/* attempt to find a port */
- for (i = 0; i < 200; ++i) {
+ trys = range->range_end - range->range_start;
+ for (i = 0; i < trys; ++i) {
int rc;
if (range->last_port >= range->range_end)
@@ -387,8 +390,8 @@
}
LOGP(DLMGCP, LOGL_ERROR,
- "Allocating a RTP/RTCP port failed 200 times 0x%x.\n",
- ENDPOINT_NUMBER(endp));
+ "Allocating a RTP/RTCP port failed %u times 0x%x.\n",
+ trys, ENDPOINT_NUMBER(endp));
return -1;
}
--
To view, visit https://gerrit.osmocom.org/9259
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic47f09869eaddd4aea817bb2517362883d65d029
Gerrit-Change-Number: 9259
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180523/b5ab2d90/attachment.htm>