You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@zookeeper.apache.org by "Andrew Grasso (JIRA)" <ji...@apache.org> on 2016/08/17 20:50:20 UTC

[jira] [Commented] (ZOOKEEPER-2516) C client calculates invalid time interval for pings et al

    [ https://issues.apache.org/jira/browse/ZOOKEEPER-2516?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15425355#comment-15425355 ] 

Andrew Grasso commented on ZOOKEEPER-2516:
------------------------------------------

Can you provide an example input for which {{calculate_interval()}} returns the wrong value?

> 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.4.0, 3.4.8, 3.5.0, 3.5.1, 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)