Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Neil Booth committed Dec 10, 2016
2 parents 97d1397 + 89d8334 commit 792f58f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
6 changes: 6 additions & 0 deletions 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
--------------

Expand Down
25 changes: 16 additions & 9 deletions server/protocol.py
Expand Up @@ -471,6 +471,7 @@ async def close_sessions(self, secs=30):
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
Expand Down Expand Up @@ -514,14 +515,18 @@ def clear_stale_sessions(self, grace=15):
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]
Expand Down Expand Up @@ -567,13 +572,14 @@ def groups_text_lines(data):
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),
Expand All @@ -589,6 +595,7 @@ def group_data(self):
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),
Expand Down
2 changes: 1 addition & 1 deletion server/version.py
@@ -1 +1 @@
VERSION = "ElectrumX 0.8.10"
VERSION = "ElectrumX 0.8.11"

0 comments on commit 792f58f

Please sign in to comment.