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

Jenkins2 asteriskteam at digium.com
Mon Apr 30 09:59:10 CDT 2018


Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/8878 )

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(-)

Approvals:
  George Joseph: Looks good to me, approved
  Jenkins2: Approved for Submit



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/8878
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: testsuite
Gerrit-Branch: 15
Gerrit-MessageType: merged
Gerrit-Change-Id: I9e540eb5a1edddb9f6dd9ae625a3cdc255e60820
Gerrit-Change-Number: 8878
Gerrit-PatchSet: 1
Gerrit-Owner: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180430/d5380b3f/attachment-0001.html>


More information about the asterisk-code-review mailing list