diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 4820bd3..180d6c9 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -1,3 +1,9 @@ +version 0.8.11 +-------------- + +- catch harmless socket exception +- show session count in groups RPC call + version 0.8.10 -------------- diff --git a/server/protocol.py b/server/protocol.py index dd6c855..5811f95 100644 --- a/server/protocol.py +++ b/server/protocol.py @@ -471,6 +471,7 @@ class ServerManager(util.LoggedClass): await asyncio.sleep(2) self.logger.info('{:,d} sessions remaining' .format(len(self.sessions))) + await asyncio.sleep(1) def add_session(self, session): # Some connections are acknowledged after the servers are closed @@ -514,14 +515,18 @@ class ServerManager(util.LoggedClass): for session in self.sessions: if session.is_closing(): if session.stop <= shutdown_cutoff and session.socket: - # Should trigger a call to connection_lost very soon - session.socket.shutdown(socket.SHUT_RDWR) - else: - if session.last_recv < stale_cutoff: - self.close_session(session) - stale.append(session.id_) + try: + # Force shut down - a call to connection_lost + # should come soon after + session.socket.shutdown(socket.SHUT_RDWR) + except socket.error: + pass + elif session.last_recv < stale_cutoff: + self.close_session(session) + stale.append(session.id_) if stale: self.logger.info('closing stale connections {}'.format(stale)) + # Clear out empty groups for key in [k for k, v in self.groups.items() if not v]: del self.groups[key] @@ -567,13 +572,14 @@ class ServerManager(util.LoggedClass): data is the return value of rpc_groups().''' - fmt = ('{:<6} {:>9} {:>6} {:>6} {:>8}' + fmt = ('{:<6} {:>9} {:>9} {:>6} {:>6} {:>8}' '{:>7} {:>9} {:>7} {:>9}') - yield fmt.format('ID', 'Bw Qta KB', 'Reqs', 'Txs', 'Subs', + yield fmt.format('ID', 'Sessions', 'Bw Qta KB', 'Reqs', 'Txs', 'Subs', 'Recv', 'Recv KB', 'Sent', 'Sent KB') - for (id_, bandwidth, reqs, txs_sent, subs, + for (id_, session_count, bandwidth, reqs, txs_sent, subs, recv_count, recv_size, send_count, send_size) in data: yield fmt.format(id_, + '{:,d}'.format(session_count), '{:,d}'.format(bandwidth // 1024), '{:,d}'.format(reqs), '{:,d}'.format(txs_sent), @@ -589,6 +595,7 @@ class ServerManager(util.LoggedClass): for group_id in sorted(self.groups.keys()): sessions = self.groups[group_id] result.append([group_id, + len(sessions), sum(s.bandwidth_used for s in sessions), sum(s.requests_remaining() for s in sessions), sum(s.txs_sent for s in sessions), diff --git a/server/version.py b/server/version.py index 646bbdf..654374a 100644 --- a/server/version.py +++ b/server/version.py @@ -1 +1 @@ -VERSION = "ElectrumX 0.8.10" +VERSION = "ElectrumX 0.8.11"