[Pidgin] #3437: Sametime 7.5 idle times too high by exactly 2^32 milliseconds

Pidgin trac at pidgin.im
Thu Jul 31 14:15:18 EDT 2008


#3437: Sametime 7.5 idle times too high by exactly 2^32 milliseconds
-----------------------+----------------------------------------------------
  Reporter:  lpm       |       Owner:  siege    
      Type:  defect    |      Status:  new      
  Priority:  minor     |   Milestone:           
 Component:  Sametime  |     Version:  2.2.1    
Resolution:            |    Keywords:  idle time
   Pending:  0         |  
-----------------------+----------------------------------------------------
Comment (by lpm):

 I looked at the code in libpurple/protocols/sametime/sametime.c and the
 debug logs and I think I know what the problem is... The problem is that
 we substract the idle timestamp reported by the buddy from the current
 (local) time. The problem is that our clock and the buddy's clock are not
 synchronized, and if the buddy's clock is running fast, the result may be
 negative. Since we're doing 32-bit unsigned arithmetic, we end up with
 something close to 2^32^ milliseconds.

 An easy workaround would be to test if the timestamp from the buddy is in
 the future, and if so assume zero idle time.

 In other words, I suggest replacing:
 {{{
 ugly_idle_len = ((time(NULL) * 1000) - idle) / 1000;
 }}}
 by:
 {{{
 ugly_idle_len = time(NULL) * 1000 ;
 if (idle > ugly_idle_len) {
   ugly_idle_len = 0 ;
 }
 else {
   ugly_idle_len =- idle ;
   ugly_idle_len /= 1000 ;
 }
 }}}

-- 
Ticket URL: <http://developer.pidgin.im/ticket/3437#comment:3>
Pidgin <http://pidgin.im>
Pidgin


More information about the Tracker mailing list