<p>George Joseph has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/testsuite/+/20081">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">utils_socket.py: Set SO_REUSEADDR and SO_REUSEPORT<br><br>Set SO_REUSEADDR and SO_REUSEPORT for both DGRAM and<br>STREAM sockets in an effort to reduce port exhaustion.<br><br>Change-Id: I913302fe69820ceb7c328fc846cd9af5551c9fdc<br>---<br>M lib/python/asterisk/utils_socket.py<br>1 file changed, 17 insertions(+), 4 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/testsuite refs/changes/81/20081/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/lib/python/asterisk/utils_socket.py b/lib/python/asterisk/utils_socket.py</span><br><span>index c8813bd..f52b0a1 100644</span><br><span>--- a/lib/python/asterisk/utils_socket.py</span><br><span>+++ b/lib/python/asterisk/utils_socket.py</span><br><span>@@ -107,16 +107,17 @@</span><br><span>     res = 0</span><br><span>     s = socket(family, socktype)</span><br><span>     try:</span><br><span style="color: hsl(0, 100%, 40%);">-        if socktype == SOCK_STREAM:</span><br><span style="color: hsl(0, 100%, 40%);">-            s.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)</span><br><span style="color: hsl(120, 100%, 40%);">+        s.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)</span><br><span style="color: hsl(120, 100%, 40%);">+        s.setsockopt(SOL_SOCKET, SO_REUSEPORT, 1)</span><br><span> </span><br><span>         s.bind((host, port))</span><br><span>         res = s.getsockname()[1]</span><br><span>     except error as e:</span><br><span>         # errno = 98 is 'Port already in use'. However, if any error occurs</span><br><span>         # just fail since we probably don't want to bind to it anyway.</span><br><span style="color: hsl(0, 100%, 40%);">-        LOGGER.debug("{0}/{1} port '{2}' is in use".format(</span><br><span style="color: hsl(0, 100%, 40%);">-            socket_type(socktype), socket_family(family), port))</span><br><span style="color: hsl(120, 100%, 40%);">+        LOGGER.debug(e)</span><br><span style="color: hsl(120, 100%, 40%);">+        LOGGER.debug("{3}: {0}/{1} port '{2}' is in use".format(</span><br><span style="color: hsl(120, 100%, 40%);">+            socket_type(socktype), socket_family(family), port, host))</span><br><span> </span><br><span>     s.close()</span><br><span>     return res</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/testsuite/+/20081">change 20081</a>. To unsubscribe, or for help writing mail filters, 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/c/testsuite/+/20081"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: testsuite </div>
<div style="display:none"> Gerrit-Branch: 18 </div>
<div style="display:none"> Gerrit-Change-Id: I913302fe69820ceb7c328fc846cd9af5551c9fdc </div>
<div style="display:none"> Gerrit-Change-Number: 20081 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>