difftime in session.c #1

Closed
allspace opened this Issue Mar 11, 2015 · 2 comments

Projects

None yet

2 participants

@allspace

I guess the order of parameters in difftime function is wrong? It results negative value ...

if (session->api_timeout > 0 &&
(seconds_to_next == 0 ||
seconds_to_next > session->api_timeout)) {
time_t now = time (NULL);
elapsed_ms = (long)(1000*difftime(start_time, now));
if (elapsed_ms > session->api_timeout) {
session->err_code = LIBSSH2_ERROR_TIMEOUT;
return LIBSSH2_ERROR_TIMEOUT;
}
ms_to_next = (session->api_timeout - elapsed_ms);
has_timeout = 1;
}
else if (ms_to_next > 0) {
has_timeout = 1;
}
else
has_timeout = 0;

@bagder
Member
bagder commented Mar 11, 2015

Yes, I can only agree! Will fix.

@bagder bagder added a commit that referenced this issue Mar 11, 2015
@bagder bagder wait_socket: wrong use of difftime()
With reversed arguments it would always return a negative value...

Bug: #1
20eb836
@bagder
Member
bagder commented Mar 11, 2015

Fixed in commit 20eb836, thanks! Case closed.

@bagder bagder closed this Mar 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment