Hadriel Kaplan created ZOOKEEPER-2516:
-----------------------------------------

             Summary: C client calculates invalid time interval for pings et al
                 Key: ZOOKEEPER-2516
                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2516
             Project: ZooKeeper
          Issue Type: Bug
          Components: c client
    Affects Versions: 3.5.1, 3.5.0, 3.4.8, 3.4.0, 3.6.0
            Reporter: Hadriel Kaplan


The C-client has a function called {{calculate_interval()}} in {{zookeeper.c}}, 
whose purpose is to determine the number of milliseconds difference between a 
start and end time. 

Unfortunately its logic is invalid, if the number of microseconds of the end 
time happens to be less than the number of microseconds of the start time - 
which it will be about half the time, since the end time could be in the next 
second interval. Such a case would yield a very big negative number, making the 
function return an invalid value.

Instead of re-creating the wheel, the {{calculate_interval()}} should use the 
{{timersub()}} function from {{time.h}} if it's available - if it's not 
#define'd, then #define it. (it's a macro, and the source code for it is 
readily available)




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to