Opened 12 years ago

Last modified 11 years ago

#4198 defect new

twisted.protocols.sip assumes DelayedCalls are scheduled by wallclock time

Reported by: ivank Owned by:
Priority: low Milestone:
Component: core Keywords:
Cc: Branch:
Author:

Description

twisted/protocols/sip.py has dc.getTime() - time.time() in two places, which is wrong because DelayedCalls are not guaranteed to be scheduled by time.time(). Perhaps it should use twisted.python.runtime.seconds(), or do something else entirely.

Using a monotonic clock breaks these tests (line numbers may be wrong):

===============================================================================
[FAIL]: twisted.test.test_sip.RegistrationTestCase.testRegister

Traceback (most recent call last):
  File "/opt/Python-latest/lib/python2.7/site-packages/twisted/test/test_sip.py", line 540, in testRegister
    int(m.headers["expires"][0]) in (3600, 3601, 3599, 3598))
twisted.trial.unittest.FailTest: None
===============================================================================
[ERROR]: twisted.test.test_sip.AuthorizationTestCase.testChallenge

Traceback (most recent call last):
  File "/opt/Python-latest/lib/python2.7/site-packages/twisted/test/test_sip.py", line 883, in testChallenge
    self.transport.written[-1],
exceptions.IndexError: list index out of range
===============================================================================
[ERROR]: twisted.test.test_sip.AuthorizationTestCase.testChallenge

Traceback (most recent call last):
  File "/opt/Python-latest/lib/python2.7/site-packages/twisted/test/test_sip.py", line 832, in _cbReg
    "bad seconds to expire: %s" % reg.secondsToExpiry)
exceptions.RuntimeError: bad seconds to expire: -1260891498

Change History (4)

comment:1 Changed 12 years ago by Glyph

DelayedCall doesn't document this as an @ivar, but I suspect it should: it has a "seconds" attribute which should be used for just this purpose.

comment:2 Changed 12 years ago by Jean-Paul Calderone

It might be better to go all the way to a documented attribute that provides IReactorTime.

comment:3 Changed 11 years ago by ivank

#2424 is the "monotonic clock for reactor" ticket

comment:4 Changed 11 years ago by <automation>

Owner: Glyph deleted
Note: See TracTickets for help on using tickets.