[
https://issues.apache.org/jira/browse/ZOOKEEPER-2516?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15425505#comment-15425505
]
Hadriel Kaplan commented on ZOOKEEPER-2516:
-------------------------------------------
Nope, you're right - it's not in {{calculate_interval()}} - I thought it was
because I was getting negative ping response numbers in our logs, a lot. But it
looks like it's just a minor issue instead: it's in {{zookeeper_process()}}
right before the debug log for {{"Got ping response in %d ms"}}. It calls
{{gettimeofday(&now, 0);}} instead of {{get_system_time(&now);}}, which on our
linux systems results in a different value (making the interval become negative
because the 'now' is a smaller value than the last_ping time). So it results in
printing negative values for ping response times in logs, but not a problem for
actually generating pings.
Sorry for the false alarm.
> 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)