Please include this patch in the next release. You can apply it directly to
src/misc.c in 1.4.0.
The timestamps generated by _libssh2_debug() measure time since a quite
arbitrary point in time. It's the first time the function was called, rounded
down to the previous whole second. So if gettimeofday() returned
1000000.123456 the first time, the time 1000000.000000 is taken as the
reference. So if the next call occurs at gettimeofday() 1000000.456789,
_libssh2_debug() would print 0.456789 as timestamp, instead of 0.333333 which
is the actual time difference. This caused some confusion as my application
mixes these printouts with similar ones with proper calculation, so the time
could seem to jump up and down by as much as a second in the logs.
My patch saves also the second fraction at the first call, and makes a proper
calculation using carry.
Ideally the function should print the time since process invocation, as
returned by getrusage(), but that would require more work to port to platforms
which don't have it. A cheaper, mostly equivalent way would be to measure time
since libssh2_init() was called.
Cryptzone Group AB
Received on 2012-02-29