Philipp Hörist pushed to branch master at gajim / python-nbxmpp
Commits: 279ec6b8 by Thilo Molitor at 2017-02-13T23:11:54+01:00 Fix smacks delayed tag addition. Only add delayed tag to stanzas saved into smacks queue, not to the ones send out directly. - - - - - 027b7a30 by Thilo Molitor at 2017-02-13T23:11:54+01:00 Fix bug in failed smacks resumption Extract correct h value when session resumption failed. Add some more logging output. - - - - - ed4a9e05 by Philipp Hörist at 2017-02-13T23:15:43+01:00 Merge branch 'smacks_rev_1.5' into 'master' Fix smacks delayed tag addition. See merge request !3 - - - - - 2 changed files: - nbxmpp/dispatcher_nb.py - nbxmpp/smacks.py Changes: ===================================== nbxmpp/dispatcher_nb.py ===================================== --- a/nbxmpp/dispatcher_nb.py +++ b/nbxmpp/dispatcher_nb.py @@ -27,6 +27,7 @@ import time import locale import re import uuid +import copy from xml.parsers.expat import ExpatError from .plugin import PlugIn from .protocol import (NS_DELAY2, NS_STREAMS, NS_XMPP_STREAMS, NS_HTTP_BIND, Iq, Presence, @@ -572,14 +573,15 @@ class XMPPDispatcher(PlugIn): # If no ID then it is a whitespace if self.sm and self.sm.enabled and ID: + stanza_copy = copy.deepcopy(stanza) # add timestamp to message stanza in queue - if stanza.getName() == 'message' and \ - (stanza.getType() == 'chat' or stanza.getType() == 'groupchat'): - our_jid = stanza.getAttr('from') + if stanza_copy.getName() == 'message' and \ + (stanza_copy.getType() == 'chat' or stanza_copy.getType() == 'groupchat'): + our_jid = stanza_copy.getAttr('from') timestamp = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime(None)) - stanza.addChild('delay', namespace=NS_DELAY2, - attrs={'from': our_jid, 'stamp': timestamp}) - self.sm.uqueue.append(stanza) + stanza_copy.addChild('delay', namespace=NS_DELAY2, + attrs={'from': our_jid or "Gajim", 'stamp': timestamp}) + self.sm.uqueue.append(stanza_copy) self.sm.out_h += 1 self._owner.Connection.send(stanza, now) ===================================== nbxmpp/smacks.py ===================================== --- a/nbxmpp/smacks.py +++ b/nbxmpp/smacks.py @@ -124,13 +124,13 @@ class Smacks(object): diff = self.out_h - h if diff < 0: - log.error('Server and client number of stanzas handled mismatch (our h: %d, server h: %d)' % (self.out_h, h)) + log.error('Server and client number of stanzas handled mismatch (our h: %d, server h: %d, #queue: %d)' % (self.out_h, h, len(self.uqueue))) while (len(self.uqueue)): #don't accumulate all messages in this case (they would otherwise all be resent on the next reconnect) self.uqueue.pop(0) elif len(self.uqueue) < diff: - log.error('Server and client number of stanzas handled mismatch (our h: %d, server h: %d)' % (self.out_h, h)) + log.error('Server and client number of stanzas handled mismatch (our h: %d, server h: %d, #queue: %d)' % (self.out_h, h, len(self.uqueue))) else: - log.debug('Got ack for outgoing stanzas (our h: %d, server h: %d), removing %d messages from queue...' % (self.out_h, h, len(self.uqueue) - diff)) + log.debug('Got ack for outgoing stanzas (our h: %d, server h: %d, #queue: %d), removing %d messages from queue...' % (self.out_h, h, len(self.uqueue), len(self.uqueue) - diff)) while (len(self.uqueue) > diff): self.uqueue.pop(0) @@ -149,12 +149,12 @@ class Smacks(object): diff = self.out_h - h if diff < 0: - log.error('Server and client number of stanzas handled mismatch on session resumption (our h: %d, server h: %d)' % (self.out_h, h)) + log.error('Server and client number of stanzas handled mismatch on session resumption (our h: %d, server h: %d. #queue: %d)' % (self.out_h, h, len(self.old_uqueue))) self.old_uqueue = [] #that's weird, but we don't resend this stanzas if the server says we don't need to elif len(self.old_uqueue) < diff: - log.error('Server and client number of stanzas handled mismatch on session resumption (our h: %d, server h: %d)' % (self.out_h, h)) + log.error('Server and client number of stanzas handled mismatch on session resumption (our h: %d, server h: %d, #queue: %d)' % (self.out_h, h, len(self.old_uqueue))) else: - log.info('Removing %d already acked stanzas from old outgoing queue (our h: %d, server h: %d, remaining in queue: %d)' % (len(self.old_uqueue) - diff, self.out_h, h, diff)) + log.info('Removing %d already acked stanzas from old outgoing queue (our h: %d, server h: %d, #queue: %d, remaining in queue: %d)' % (len(self.old_uqueue) - diff, self.out_h, h, len(self.old_uqueue), diff)) while (len(self.old_uqueue) > diff): self.old_uqueue.pop(0) @@ -178,7 +178,7 @@ class Smacks(object): self._owner._on_auth_bind(None) self.failed_resume = True - h = stanza.getTag('item-not-found').getAttr('h') + h = stanza.getAttr('h') log.info('Session resumption failed (item-not-found), server h: %s' % str(h)) if not h: return @@ -187,12 +187,12 @@ class Smacks(object): diff = self.out_h - h if diff < 0: - log.error('Server and client number of stanzas handled mismatch on session resumption (our h: %d, server h: %d)' % (self.out_h, h)) + log.error('Server and client number of stanzas handled mismatch on session resumption (our h: %d, server h: %d, #queue: %d)' % (self.out_h, h, len(self.old_uqueue))) self.old_uqueue = [] #that's weird, but we don't resend this stanzas if the server says we don't need to elif len(self.old_uqueue) < diff: - log.error('Server and client number of stanzas handled mismatch on session resumption (our h: %d, server h: %d)' % (self.out_h, h)) + log.error('Server and client number of stanzas handled mismatch on session resumption (our h: %d, server h: %d, #queue: %d)' % (self.out_h, h, len(self.old_uqueue))) else: - log.info('Removing %d already acked stanzas from old outgoing queue (our h: %d, server h: %d, remaining in queue: %d)' % (len(self.old_uqueue) - diff, self.out_h, h, diff)) + log.info('Removing %d already acked stanzas from old outgoing queue (our h: %d, server h: %d, #queue: %d, remaining in queue: %d)' % (len(self.old_uqueue) - diff, self.out_h, h, len(self.old_uqueue), diff)) while (len(self.old_uqueue) > diff): self.old_uqueue.pop(0) return View it on GitLab: https://dev.gajim.org/gajim/python-nbxmpp/compare/8f1c3b113c75f1f81fcdd8807d3dcd2335feb5f2...ed4a9e051c142eb1ebc4634361baa42918198c6d
_______________________________________________ Commits mailing list Commits@gajim.org https://lists.gajim.org/cgi-bin/listinfo/commits