<p>Jenkins2 <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/8865">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Corey Farrell: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved
Jenkins2: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">utils_socket: range of random ports searched only once<br><br>If a range (greater than 1) of random ports was asked for, and if a port in<br>range was not available an exception was thrown stating the port in range<br>was not free.<br><br>This patch makes it so the exception is caught and a new random port range is<br>tried again (up to "attempts" tries) before quitting.<br><br>Change-Id: I96affa9df38acf569f5d3c0965ac7b78d865455d<br>---<br>M lib/python/asterisk/utils_socket.py<br>1 file changed, 16 insertions(+), 5 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/lib/python/asterisk/utils_socket.py b/lib/python/asterisk/utils_socket.py<br>index 2a11c97..1f62f13 100644<br>--- a/lib/python/asterisk/utils_socket.py<br>+++ b/lib/python/asterisk/utils_socket.py<br>@@ -195,6 +195,9 @@<br> if not isinstance(ports, list):<br> ports = list(ports)<br> <br>+ LOGGER.debug("Checking the following {0}/{1} ports for availability: "<br>+ "{2}".format(socket_type(socktype), socket_family(family), ports))<br>+<br> res = []<br> for port in ports:<br> for attempt in range(attempts):<br>@@ -238,11 +241,19 @@<br> <br> # Need a random port first<br> port = self.get_avail(host, 0, socktype, family)<br>- ports = self.get_avail(<br>- host, range(port[0] + step, port[0] + num, step),<br>- socktype, family, attempts)<br>- if ports:<br>- return port + ports<br>+<br>+ if abs(num) <= 1:<br>+ return port<br>+<br>+ try:<br>+ ports = self.get_avail(<br>+ host, range(port[0] + step, port[0] + num, step),<br>+ socktype, family, attempts)<br>+ except PortError:<br>+ # At least one port not free, try again<br>+ continue<br>+<br>+ return port + ports<br> <br> raise PortError(socktype, family, attempts=attempts)<br> <br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/8865">change 8865</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/8865"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: testsuite </div>
<div style="display:none"> Gerrit-Branch: 15 </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: I96affa9df38acf569f5d3c0965ac7b78d865455d </div>
<div style="display:none"> Gerrit-Change-Number: 8865 </div>
<div style="display:none"> Gerrit-PatchSet: 3 </div>
<div style="display:none"> Gerrit-Owner: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Benjamin Keith Ford <bford@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Corey Farrell <git@cfware.com> </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>