Skip to content
This repository was archived by the owner on Apr 27, 2019. It is now read-only.

Commit 2ea1e10

Browse files
committed
More robust connection failure detection. There should be absolutely no more hanged clients.
1 parent 428a7c1 commit 2ea1e10

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

server.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,8 @@ def die(self):
441441
except AttributeError:
442442
pass
443443

444+
def connectionFailed(self, *args, **kwargs):
445+
self.connectionLost()
444446

445447
class ClientProtocol(Protocol):
446448
"""
@@ -503,7 +505,6 @@ def dataReceived(self, data):
503505
else:
504506
self.packet_stream += data
505507

506-
507508
class StarryPyServerFactory(ServerFactory):
508509
"""
509510
Factory which creates `StarryPyServerProtocol` instances.
@@ -572,9 +573,9 @@ def reap_dead_protocols(self):
572573
protocol.connectionLost()
573574
count += 1
574575
if count == 1:
575-
logger.debug("1 connection reaped.")
576+
logger.info("1 connection reaped.")
576577
elif count > 1:
577-
logger.debug("%d connections reaped.")
578+
logger.info("%d connections reaped.")
578579
else:
579580
logger.debug("No connections reaped.")
580581

@@ -622,8 +623,6 @@ def buildProtocol(self, address):
622623
config.upstream_hostname, config.upstream_port))
623624
logger.critical(
624625
"Please ensure that you are running starbound_server on the correct port and that is reflected in the StarryPy configuration.")
625-
sock.shutdown()
626-
sock.close()
627626
sys.exit()
628627
sock.shutdown(SHUT_RDWR)
629628
sock.close()

0 commit comments

Comments
 (0)