comparison sat/plugins/plugin_xep_0198.py @ 3019:c9f03b1eb64d

plugin XEP-0198: catch and log an error if buffer is unexpectedly empty
author Goffi <goffi@goffi.org>
date Sat, 20 Jul 2019 20:55:17 +0200
parents 93da7c6f8e0c
children af9d71303605
comparison
equal deleted inserted replaced
3018:758bee45612b 3019:c9f03b1eb64d
243 243
244 def updateBuffer(self, session, server_acked): 244 def updateBuffer(self, session, server_acked):
245 """Update buffer and buffer_index""" 245 """Update buffer and buffer_index"""
246 if server_acked > session.buffer_idx: 246 if server_acked > session.buffer_idx:
247 diff = server_acked - session.buffer_idx 247 diff = server_acked - session.buffer_idx
248 for i in xrange(diff): 248 try:
249 session.buffer.pop() 249 for i in xrange(diff):
250 session.buffer.pop()
251 except IndexError:
252 log.error(
253 u"error while cleaning buffer, invalid index (buffer is empty):\n"
254 u"diff = {diff}\n"
255 u"server_acked = {server_acked}\n"
256 u"buffer_idx = {buffer_id}".format(
257 diff=diff, server_acked=server_acked,
258 buffer_id=session.buffer_idx))
250 session.buffer_idx += diff 259 session.buffer_idx += diff
251 260
252 def replayBuffer(self, client, buffer_, discard_results=False): 261 def replayBuffer(self, client, buffer_, discard_results=False):
253 """Resend all stanza in buffer 262 """Resend all stanza in buffer
254 263