[Asterisk-code-review] utils socket: Set option to reuse socket (testsuite[15])

Kevin Harwell asteriskteam at digium.com
Tue May 8 12:49:12 CDT 2018


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


Change subject: utils_socket: Set option to reuse socket
......................................................................

utils_socket: Set option to reuse socket

If the socket (the one found to be available) was not torn down fast enough
then SIPp could report an "in use" error. This patch sets the reuse address
option on the socket. This should allow another binding to take place for
the same address:port combination if the socket is in the TIME_WAIT state,
which it should be after closing, but waiting on the OS.

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



  git pull ssh://gerrit.asterisk.org:29418/testsuite refs/changes/43/8943/1

diff --git a/lib/python/asterisk/utils_socket.py b/lib/python/asterisk/utils_socket.py
index 158592d..ccbc2cc 100644
--- a/lib/python/asterisk/utils_socket.py
+++ b/lib/python/asterisk/utils_socket.py
@@ -73,6 +73,9 @@
     res = 0
     s = socket(family, socktype)
     try:
+        # Set SO_REUSEADDR on the socket. This should allow others
+        # to bind the same address:port if the socket is in TIME_WAIT
+        s.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
         s.bind((host, port))
         res = s.getsockname()[1]
     except error as e:

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

Gerrit-Project: testsuite
Gerrit-Branch: 15
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5eb84e77c8825310f1c10f21c54b19c4ed694175
Gerrit-Change-Number: 8943
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/20180508/8a6aabc6/attachment.html>


More information about the asterisk-code-review mailing list