Skip to content

Commit

Permalink
simplify diff / patch
Browse files Browse the repository at this point in the history
  • Loading branch information
dirk-thomas authored Feb 1, 2018
1 parent 9c2365d commit e5112a7
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions tools/rosmaster/src/rosmaster/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,19 @@ def xmlrpcapi(uri):


def close_half_closed_sockets():
if hasattr(socket, 'TCP_INFO'):
for proxy in _proxies.values():
transport = proxy("transport")
if transport._connection and transport._connection[1] is not None and transport._connection[1].sock is not None:
try:
state = transport._connection[1].sock.getsockopt(socket.SOL_TCP, socket.TCP_INFO)
except socket.error as e: # catch [Errno 92] Protocol not available
if e.args[0] is errno.ENOPROTOOPT:
return
raise
if state == 8: # CLOSE_WAIT
transport.close()
if not hasattr(socket, 'TCP_INFO'):
return
for proxy in _proxies.values():
transport = proxy("transport")
if transport._connection and transport._connection[1] is not None and transport._connection[1].sock is not None:
try:
state = transport._connection[1].sock.getsockopt(socket.SOL_TCP, socket.TCP_INFO)
except socket.error as e: # catch [Errno 92] Protocol not available
if e.args[0] is errno.ENOPROTOOPT:
return
raise
if state == 8: # CLOSE_WAIT
transport.close()


def remove_server_proxy(uri):
Expand Down

0 comments on commit e5112a7

Please sign in to comment.