Skip to content

Commit

Permalink
Make credit_time, expire_time, no_progress_time and no_reply_time
Browse files Browse the repository at this point in the history
working properly with MonoTimes.

Issue:	#36
  • Loading branch information
sobomax committed Oct 23, 2020
1 parent 8adb5f9 commit 60a0fe4
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion sippy/UA.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ def cancelCreditTimer(self):

def startCreditTimer(self, rtime):
if self.credit_time != None:
self.credit_times[0] = rtime + self.credit_time
self.credit_times[0] = rtime.getOffsetCopy(self.credit_time)
self.credit_time = None
try:
credit_time = min([x for x in self.credit_times.values() if x != None])
Expand Down
12 changes: 6 additions & 6 deletions sippy/UacStateIdle.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,26 +75,26 @@ def recvEvent(self, event):
laddress = self.ua.source_address, cb_ifver = 2, compact = self.ua.compact_sip)
self.ua.auth = None
if self.ua.expire_time != None:
self.ua.expire_time += event.rtime
self.ua.expire_mtime = event.rtime.getOffsetCopy(self.ua.expire_time)
if self.ua.no_progress_time != None:
self.ua.no_progress_time += event.rtime
self.ua.no_progress_mtime = event.rtime.getOffsetCopy(self.ua.no_progress_time)
if self.ua.expire_time != None and self.ua.no_progress_time >= self.ua.expire_time:
self.ua.no_progress_time = None
if self.ua.no_reply_time != None:
if self.ua.no_reply_time < 32:
self.ua.no_reply_time += event.rtime
no_reply_mtime = event.rtime.getOffsetCopy(self.ua.no_reply_time)
if self.ua.expire_time != None and self.ua.no_reply_time >= self.ua.expire_time:
self.ua.no_reply_time = None
elif self.ua.no_progress_time != None and self.ua.no_reply_time >= self.ua.no_progress_time:
self.ua.no_reply_time = None
else:
self.ua.no_reply_time = None
if self.ua.no_reply_time != None:
self.ua.no_reply_timer = TimeoutAbsMono(self.ua.no_reply_expires, self.ua.no_reply_time)
self.ua.no_reply_timer = TimeoutAbsMono(self.ua.no_reply_expires, no_reply_mtime)
elif self.ua.no_progress_time != None:
self.ua.no_progress_timer = TimeoutAbsMono(self.ua.no_progress_expires, self.ua.no_progress_time)
self.ua.no_progress_timer = TimeoutAbsMono(self.ua.no_progress_expires, self.ua.no_progress_mtime)
elif self.ua.expire_time != None:
self.ua.expire_timer = TimeoutAbsMono(self.ua.expires, self.ua.expire_time)
self.ua.expire_timer = TimeoutAbsMono(self.ua.expires, self.ua.expire_mtime)
return (UacStateTrying,)
if isinstance(event, CCEventFail) or isinstance(event, CCEventRedirect) or isinstance(event, CCEventDisconnect):
return (UaStateDead, self.ua.disc_cbs, event.rtime, event.origin)
Expand Down
6 changes: 3 additions & 3 deletions sippy/UacStateTrying.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ def recvResponse(self, resp, tr):
self.ua.no_reply_timer.cancel()
self.ua.no_reply_timer = None
if code == 100 and self.ua.no_progress_time != None:
self.ua.no_progress_timer = TimeoutAbsMono(self.ua.no_progress_expires, self.ua.no_progress_time)
self.ua.no_progress_timer = TimeoutAbsMono(self.ua.no_progress_expires, self.ua.no_progress_mtime)
elif code < 200 and self.ua.expire_time != None:
self.ua.expire_timer = TimeoutAbsMono(self.ua.expires, self.ua.expire_time)
self.ua.expire_timer = TimeoutAbsMono(self.ua.expires, self.ua.expire_mtime)
if code == 100:
if self.ua.p100_ts == None:
self.ua.p100_ts = resp.rtime
Expand All @@ -57,7 +57,7 @@ def recvResponse(self, resp, tr):
self.ua.no_progress_timer.cancel()
self.ua.no_progress_timer = None
if code < 200 and self.ua.expire_time != None:
self.ua.expire_timer = TimeoutAbsMono(self.ua.expires, self.ua.expire_time)
self.ua.expire_timer = TimeoutAbsMono(self.ua.expires, self.ua.expire_mtime)
if code < 200:
event = CCEventRing(scode, rtime = resp.rtime, origin = self.ua.origin)
if body != None:
Expand Down
8 changes: 4 additions & 4 deletions sippy/UasStateIdle.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,15 @@ def recvRequest(self, req):
except:
pass
if self.ua.expire_time != None:
self.ua.expire_time += event.rtime
self.ua.expire_mtime = event.rtime.getOffsetCopy(self.ua.expire_time)
if self.ua.no_progress_time != None:
self.ua.no_progress_time += event.rtime
self.ua.no_progress_mtime = event.rtime.getOffsetCopy(self.ua.no_progress_time)
if self.ua.expire_time != None and self.ua.no_progress_time >= self.ua.expire_time:
self.ua.no_progress_time = None
if self.ua.no_progress_time != None:
self.ua.no_progress_timer = TimeoutAbsMono(self.ua.no_progress_expires, self.ua.no_progress_time)
self.ua.no_progress_timer = TimeoutAbsMono(self.ua.no_progress_expires, self.ua.no_progress_mtime)
elif self.ua.expire_time != None:
self.ua.expire_timer = TimeoutAbsMono(self.ua.expires, self.ua.expire_time)
self.ua.expire_timer = TimeoutAbsMono(self.ua.expires, self.ua.expire_mtime)
if body != None:
if self.ua.on_remote_sdp_change != None:
self.ua.on_remote_sdp_change(body, lambda x: self.ua.delayed_remote_sdp_update(event, x))
Expand Down
2 changes: 1 addition & 1 deletion sippy/UasStateTrying.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def recvEvent(self, event):
self.ua.no_progress_timer.cancel()
self.ua.no_progress_timer = None
if self.ua.expire_time != None:
self.ua.expire_timer = TimeoutAbsMono(self.ua.expires, self.ua.expire_time)
self.ua.expire_timer = TimeoutAbsMono(self.ua.expires, self.ua.expire_mtime)
if self.ua.p1xx_ts == None:
self.ua.p1xx_ts = event.rtime
return (UasStateRinging, self.ua.ring_cbs, event.rtime, event.origin, code)
Expand Down

0 comments on commit 60a0fe4

Please sign in to comment.