Compare commits

..

2 Commits

Author SHA1 Message Date
Xavier Roche
9b7601a987 htslib: fix mtime_local sub-second precision on POSIX
mtime_local() returns milliseconds since the epoch, but the POSIX
branch divided tv_usec (microseconds) by 1000000 instead of 1000,
dropping the entire millisecond term. The clock only advanced at
whole-second boundaries, so every sub-second delta the callers compute
(request/connect timing, transfer-rate smoothing) read as zero. The
Windows ftime() branch was already correct.

Found while documenting the public API (#382).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Xavier Roche <roche@httrack.com>
2026-06-17 22:03:16 +02:00
Xavier Roche
4ec38c4e66 Merge pull request #382 from xroche/docs/api-httrack-library
Document the public C API with contract comments
2026-06-17 21:17:24 +02:00

View File

@@ -2580,8 +2580,8 @@ HTSEXT_API TStamp mtime_local(void) {
assert(! "gettimeofday");
}
return (TStamp) (((TStamp) tv.tv_sec * (TStamp) 1000)
+ ((TStamp) tv.tv_usec / (TStamp) 1000000));
return (TStamp) (((TStamp) tv.tv_sec * (TStamp) 1000) +
((TStamp) tv.tv_usec / (TStamp) 1000));
#else
struct timeb B;
ftime(&B);