Philipp Hörist pushed to branch master at gajim / python-nbxmpp

Commits:

2 changed files:

Changes:

  • nbxmpp/dispatcher_nb.py
    ... ... @@ -27,6 +27,7 @@ import time
    27 27
     import locale
    
    28 28
     import re
    
    29 29
     import uuid
    
    30
    +import copy
    
    30 31
     from xml.parsers.expat import ExpatError
    
    31 32
     from .plugin import PlugIn
    
    32 33
     from .protocol import (NS_DELAY2, NS_STREAMS, NS_XMPP_STREAMS, NS_HTTP_BIND, Iq, Presence,
    
    ... ... @@ -572,14 +573,15 @@ class XMPPDispatcher(PlugIn):
    572 573
     
    
    573 574
             # If no ID then it is a whitespace
    
    574 575
             if self.sm and self.sm.enabled and ID:
    
    576
    +            stanza_copy = copy.deepcopy(stanza)
    
    575 577
                 # add timestamp to message stanza in queue
    
    576
    -            if stanza.getName() == 'message' and \
    
    577
    -            (stanza.getType() == 'chat' or stanza.getType() == 'groupchat'):
    
    578
    -                our_jid = stanza.getAttr('from')
    
    578
    +            if stanza_copy.getName() == 'message' and \
    
    579
    +            (stanza_copy.getType() == 'chat' or stanza_copy.getType() == 'groupchat'):
    
    580
    +                our_jid = stanza_copy.getAttr('from')
    
    579 581
                     timestamp = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime(None))
    
    580
    -                stanza.addChild('delay', namespace=NS_DELAY2,
    
    581
    -                        attrs={'from': our_jid, 'stamp': timestamp})
    
    582
    -            self.sm.uqueue.append(stanza)
    
    582
    +                stanza_copy.addChild('delay', namespace=NS_DELAY2,
    
    583
    +                        attrs={'from': our_jid or "Gajim", 'stamp': timestamp})
    
    584
    +            self.sm.uqueue.append(stanza_copy)
    
    583 585
                 self.sm.out_h += 1
    
    584 586
     
    
    585 587
             self._owner.Connection.send(stanza, now)
    

  • nbxmpp/smacks.py
    ... ... @@ -124,13 +124,13 @@ class Smacks(object):
    124 124
             diff = self.out_h - h
    
    125 125
     
    
    126 126
             if diff < 0:
    
    127
    -            log.error('Server and client number of stanzas handled mismatch (our h: %d, server h: %d)' % (self.out_h, h))
    
    127
    +            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)))
    
    128 128
                 while (len(self.uqueue)):        #don't accumulate all messages in this case (they would otherwise all be resent on the next reconnect)
    
    129 129
                     self.uqueue.pop(0)
    
    130 130
             elif len(self.uqueue) < diff:
    
    131
    -            log.error('Server and client number of stanzas handled mismatch (our h: %d, server h: %d)' % (self.out_h, h))
    
    131
    +            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)))
    
    132 132
             else:
    
    133
    -            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))
    
    133
    +            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))
    
    134 134
                 while (len(self.uqueue) > diff):
    
    135 135
                     self.uqueue.pop(0)
    
    136 136
                         
    
    ... ... @@ -149,12 +149,12 @@ class Smacks(object):
    149 149
             diff = self.out_h - h
    
    150 150
     
    
    151 151
             if diff < 0:
    
    152
    -            log.error('Server and client number of stanzas handled mismatch on session resumption (our h: %d, server h: %d)' % (self.out_h, h))
    
    152
    +            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)))
    
    153 153
                 self.old_uqueue = []        #that's weird, but we don't resend this stanzas if the server says we don't need to
    
    154 154
             elif len(self.old_uqueue) < diff:
    
    155
    -            log.error('Server and client number of stanzas handled mismatch on session resumption (our h: %d, server h: %d)' % (self.out_h, h))
    
    155
    +            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)))
    
    156 156
             else:
    
    157
    -            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))
    
    157
    +            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))
    
    158 158
                 while (len(self.old_uqueue) > diff):
    
    159 159
                     self.old_uqueue.pop(0)
    
    160 160
     
    
    ... ... @@ -178,7 +178,7 @@ class Smacks(object):
    178 178
                 self._owner._on_auth_bind(None)
    
    179 179
                 self.failed_resume = True
    
    180 180
                 
    
    181
    -            h = stanza.getTag('item-not-found').getAttr('h')
    
    181
    +            h = stanza.getAttr('h')
    
    182 182
                 log.info('Session resumption failed (item-not-found), server h: %s' % str(h))
    
    183 183
                 if not h:
    
    184 184
                     return
    
    ... ... @@ -187,12 +187,12 @@ class Smacks(object):
    187 187
                 diff = self.out_h - h
    
    188 188
     
    
    189 189
                 if diff < 0:
    
    190
    -                log.error('Server and client number of stanzas handled mismatch on session resumption (our h: %d, server h: %d)' % (self.out_h, h))
    
    190
    +                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)))
    
    191 191
                     self.old_uqueue = []        #that's weird, but we don't resend this stanzas if the server says we don't need to
    
    192 192
                 elif len(self.old_uqueue) < diff:
    
    193
    -                log.error('Server and client number of stanzas handled mismatch on session resumption (our h: %d, server h: %d)' % (self.out_h, h))
    
    193
    +                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)))
    
    194 194
                 else:
    
    195
    -                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))
    
    195
    +                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))
    
    196 196
                     while (len(self.old_uqueue) > diff):
    
    197 197
                         self.old_uqueue.pop(0)
    
    198 198
                 return