From ca46821c01923e631f543030d583ba135562e681 Mon Sep 17 00:00:00 2001 From: Joel Rosdahl Date: Sun, 16 Aug 2015 22:42:35 +0200 Subject: Handle quickly disconnecting client without crashing --- CHANGES | 1 + miniircd | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index dd2d986..4a85b25 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,7 @@ Unreleased * Find certificate specified with relative path when using --daemon. + * Handle quickly disconnecting client without crashing. 1.1 (2015-05-22) diff --git a/miniircd b/miniircd index 34847e8..c864188 100755 --- a/miniircd +++ b/miniircd @@ -793,9 +793,15 @@ class Server(object): "SSL error for connection from %s:%s: %s" % ( addr[0], addr[1], e)) continue - self.clients[conn] = Client(self, conn) - self.print_info("Accepted connection from %s:%s." % ( - addr[0], addr[1])) + try: + self.clients[conn] = Client(self, conn) + self.print_info("Accepted connection from %s:%s." % ( + addr[0], addr[1])) + except socket.error as e: + try: + conn.close() + except: + pass for x in owtd: if x in self.clients: # client may have been disconnected self.clients[x].socket_writable_notification() -- cgit v1.2.3