Commit 53892171 authored by Philipp Hörist's avatar Philipp Hörist

Merge branch 'master' into 'master'

send unrequested ack when we haven't acked more than 100 stanza

Closes #45 and gajim#8758

See merge request !10
parents 5a37180d 9dcd1fa3
...@@ -589,6 +589,8 @@ class XMPPDispatcher(PlugIn): ...@@ -589,6 +589,8 @@ class XMPPDispatcher(PlugIn):
if len(self.sm.uqueue) > self.sm.max_queue: if len(self.sm.uqueue) > self.sm.max_queue:
self.sm.request_ack() self.sm.request_ack()
if (self.sm.in_h - self.sm.last_sent_in_h) > 100:
self.sm.send_ack()
return ID return ID
......
...@@ -18,6 +18,7 @@ class Smacks(object): ...@@ -18,6 +18,7 @@ class Smacks(object):
self.con = con # Connection object self.con = con # Connection object
self.out_h = 0 # Outgoing stanzas handled self.out_h = 0 # Outgoing stanzas handled
self.in_h = 0 # Incoming stanzas handled self.in_h = 0 # Incoming stanzas handled
self.last_sent_in_h = 0 # Last acked stanza.
self.uqueue = [] # Unhandled stanzas queue self.uqueue = [] # Unhandled stanzas queue
self.old_uqueue = [] # Unhandled stanzas queue of the last session self.old_uqueue = [] # Unhandled stanzas queue of the last session
self.session_id = None self.session_id = None
...@@ -68,6 +69,7 @@ class Smacks(object): ...@@ -68,6 +69,7 @@ class Smacks(object):
log.debug("Clearing smacks uqueue") log.debug("Clearing smacks uqueue")
self.uqueue = [] self.uqueue = []
self.in_h = 0 self.in_h = 0
self.last_sent_in_h = 0
self.out_h = 0 self.out_h = 0
self.session_id = None self.session_id = None
self.enabled = True self.enabled = True
...@@ -99,11 +101,13 @@ class Smacks(object): ...@@ -99,11 +101,13 @@ class Smacks(object):
self.uqueue = [] self.uqueue = []
resume = Acks() resume = Acks()
resume.buildResume(self.in_h, self.session_id) resume.buildResume(self.in_h, self.session_id)
self.last_sent_in_h = self.in_h
self._owner.Connection.send(resume, False) self._owner.Connection.send(resume, False)
def send_ack(self, disp, stanza): def send_ack(self, disp=None, stanza=None):
ack = Acks() ack = Acks()
ack.buildAnswer(self.in_h) ack.buildAnswer(self.in_h)
self.last_sent_in_h = self.in_h
self._owner.Connection.send(ack, False) self._owner.Connection.send(ack, False)
def send_closing_ack(self): def send_closing_ack(self):
...@@ -112,6 +116,7 @@ class Smacks(object): ...@@ -112,6 +116,7 @@ class Smacks(object):
return return
ack = Acks() ack = Acks()
ack.buildAnswer(self.in_h) ack.buildAnswer(self.in_h)
self.last_sent_in_h = self.in_h
self._owner.Connection.send(ack, True) self._owner.Connection.send(ack, True)
def request_ack(self): def request_ack(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment