From 77ed0c35ea2f05a367d82395bcec28901bef2606 Mon Sep 17 00:00:00 2001 From: Erica Portnoy Date: Thu, 13 Oct 2016 13:53:17 -0700 Subject: [PATCH] Match socket testing behavior to ACME standalone socket reuse behavior. Aggressively reuse ports, ignoring TIME_WAIT. (#3631) --- certbot/plugins/util.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/certbot/plugins/util.py b/certbot/plugins/util.py index 915b531c5..786f6ca92 100644 --- a/certbot/plugins/util.py +++ b/certbot/plugins/util.py @@ -91,6 +91,7 @@ def already_listening_socket(port, renewer=False): try: testsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0) + testsocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) try: testsocket.bind(("", port)) except socket.error: @@ -129,8 +130,7 @@ def already_listening_psutil(port, renewer=False): return False listeners = [conn.pid for conn in net_connections - if (conn.status == 'LISTEN' or - conn.status == 'TIME_WAIT') and + if conn.status == 'LISTEN' and conn.type == socket.SOCK_STREAM and conn.laddr[1] == port] try: