From cfb92a139fec0b9a75f12682e9d7e31f3bec8baf Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Sat, 10 Dec 2016 13:52:05 +0900 Subject: [PATCH] Prefer transport.abort() --- lib/jsonrpc.py | 3 --- server/protocol.py | 10 ++-------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/lib/jsonrpc.py b/lib/jsonrpc.py index f44f4c5..9c83be2 100644 --- a/lib/jsonrpc.py +++ b/lib/jsonrpc.py @@ -10,7 +10,6 @@ import asyncio import json import numbers -import socket import time from lib.util import LoggedClass @@ -152,7 +151,6 @@ class JSONRPC(asyncio.Protocol, LoggedClass): self.bandwidth_used = 0 self.bandwidth_limit = 5000000 self.transport = None - self.socket = None # Parts of an incomplete JSON line. We buffer them until # getting a newline. self.parts = [] @@ -188,7 +186,6 @@ class JSONRPC(asyncio.Protocol, LoggedClass): '''Handle an incoming client connection.''' self.transport = transport self.peer_info = transport.get_extra_info('peername') - self.socket = transport.get_extra_info('socket') def connection_lost(self, exc): '''Handle client disconnection.''' diff --git a/server/protocol.py b/server/protocol.py index 5811f95..af1849f 100644 --- a/server/protocol.py +++ b/server/protocol.py @@ -11,7 +11,6 @@ import asyncio import codecs import json -import socket import ssl import time import traceback @@ -514,13 +513,8 @@ class ServerManager(util.LoggedClass): stale = [] for session in self.sessions: if session.is_closing(): - if session.stop <= shutdown_cutoff and session.socket: - try: - # Force shut down - a call to connection_lost - # should come soon after - session.socket.shutdown(socket.SHUT_RDWR) - except socket.error: - pass + if session.stop <= shutdown_cutoff: + session.transport.abort() elif session.last_recv < stale_cutoff: self.close_session(session) stale.append(session.id_)