[Asterisk-code-review] utils socket: don't reuse port variable (testsuite[13])

Kevin Harwell asteriskteam at digium.com
Mon Apr 30 09:45:58 CDT 2018


Kevin Harwell has uploaded this change for review. ( https://gerrit.asterisk.org/8876


Change subject: utils_socket: don't reuse port variable
......................................................................

utils_socket: don't reuse port variable

The port parameter variable was being written over and reused in the 'get_range'
random port retrieval section. If a second attempt needed to be made to get a
free port then it would end up falling into the first case (port != 0) and
cause a concatentation error since port was now a list.

This patch makes it so the second case uses a completely new variable name.

Change-Id: I9e540eb5a1edddb9f6dd9ae625a3cdc255e60820
---
M lib/python/asterisk/utils_socket.py
1 file changed, 5 insertions(+), 5 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/testsuite refs/changes/76/8876/1

diff --git a/lib/python/asterisk/utils_socket.py b/lib/python/asterisk/utils_socket.py
index 1f62f13..158592d 100644
--- a/lib/python/asterisk/utils_socket.py
+++ b/lib/python/asterisk/utils_socket.py
@@ -240,20 +240,20 @@
                     socktype, family, attempts)
 
             # Need a random port first
-            port = self.get_avail(host, 0, socktype, family)
+            avail = self.get_avail(host, 0, socktype, family)
 
             if abs(num) <= 1:
-                return port
+                return avail
 
             try:
-                ports = self.get_avail(
-                    host, range(port[0] + step, port[0] + num, step),
+                avails = self.get_avail(
+                    host, range(avail[0] + step, avail[0] + num, step),
                     socktype, family, attempts)
             except PortError:
                 # At least one port not free, try again
                 continue
 
-            return port + ports
+            return avail + avails
 
         raise PortError(socktype, family, attempts=attempts)
 

-- 
To view, visit https://gerrit.asterisk.org/8876
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: testsuite
Gerrit-Branch: 13
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9e540eb5a1edddb9f6dd9ae625a3cdc255e60820
Gerrit-Change-Number: 8876
Gerrit-PatchSet: 1
Gerrit-Owner: Kevin Harwell <kharwell at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180430/1dcb4719/attachment.html>


More information about the asterisk-code-review mailing list