From 625508f5c6587f527efd4eb19ec9451cc466f63e Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Sat, 3 Dec 2016 10:56:55 +0900 Subject: [PATCH 1/4] Send no ID for batch request errors Fixes #54 --- lib/jsonrpc.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/jsonrpc.py b/lib/jsonrpc.py index 6329a83..5688f84 100644 --- a/lib/jsonrpc.py +++ b/lib/jsonrpc.py @@ -211,16 +211,17 @@ class JSONRPC(asyncio.Protocol, LoggedClass): if self.transport.is_closing(): return + id_ = payload.get('id') if isinstance(payload, dict) else None try: data = (json.dumps(payload) + '\n').encode() except TypeError: msg = 'JSON encoding failure: {}'.format(payload) self.logger.error(msg) - self.send_json_error(msg, self.INTERNAL_ERROR, payload.get('id')) + self.send_json_error(msg, self.INTERNAL_ERROR, id_) else: if len(data) > max(1000, self.max_send): - self.send_json_error('request too large', self.INVALID_REQUEST, - payload.get('id')) + self.send_json_error('request too large', + self.INVALID_REQUEST, id_) raise self.LargeRequestError else: self.send_count += 1 From e59279cc08cb3d1369d185857b6bab88a13d0185 Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Sat, 3 Dec 2016 11:01:57 +0900 Subject: [PATCH 2/4] Reduce message spew on clean shutdown --- electrumx_server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/electrumx_server.py b/electrumx_server.py index 7129a8a..a749949 100755 --- a/electrumx_server.py +++ b/electrumx_server.py @@ -41,7 +41,7 @@ def main_loop(): def on_exception(loop, context): '''Suppress spurious messages it appears we cannot control.''' message = context.get('message') - if not message in SUPPRESS_MESSAGES: + if not loop.is_closed() and not message in SUPPRESS_MESSAGES: if not ('task' in context and 'accept_connection2()' in repr(context.get('task'))): loop.default_exception_handler(context) From c16792fb8932b0b62406c796914f867304a992ab Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Sat, 3 Dec 2016 11:03:27 +0900 Subject: [PATCH 3/4] Only wait 30 secsonds on shutdown --- server/protocol.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/protocol.py b/server/protocol.py index bae092d..20157a8 100644 --- a/server/protocol.py +++ b/server/protocol.py @@ -341,7 +341,7 @@ class ServerManager(util.LoggedClass): if self.sessions: await self.close_sessions() - async def close_sessions(self, secs=60): + async def close_sessions(self, secs=30): self.logger.info('cleanly closing client sessions, please wait...') for session in self.sessions: self.close_session(session) From 7e3ca6926d7fbe558af79556fd5b345fc10368a0 Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Sat, 3 Dec 2016 11:06:52 +0900 Subject: [PATCH 4/4] Prepare 0.7.20 --- RELEASE-NOTES | 6 ++++++ server/version.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index a3d8a25..731d580 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -1,3 +1,9 @@ +version 0.7.20 +-------------- + +- fix for errors during batch requests (issue #54) +- don't log errors on shutdown after giving sockets time to close + version 0.7.19 -------------- diff --git a/server/version.py b/server/version.py index 0aa8848..c901cc6 100644 --- a/server/version.py +++ b/server/version.py @@ -1 +1 @@ -VERSION = "ElectrumX 0.7.19" +VERSION = "ElectrumX 0.7.20"