New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

difftime in session.c #1

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

Comments

Projects
None yet
2 participants
@allspace

allspace commented Mar 11, 2015

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

This comment has been minimized.

Show comment
Hide comment
@bagder

bagder Mar 11, 2015

Member

Yes, I can only agree! Will fix.

Member

bagder commented Mar 11, 2015

Yes, I can only agree! Will fix.

bagder added a commit that referenced this issue Mar 11, 2015

wait_socket: wrong use of difftime()
With reversed arguments it would always return a negative value...

Bug: #1
@bagder

This comment has been minimized.

Show comment
Hide comment
@bagder

bagder Mar 11, 2015

Member

Fixed in commit 20eb836, thanks! Case closed.

Member

bagder commented Mar 11, 2015

Fixed in commit 20eb836, thanks! Case closed.

@bagder bagder closed this Mar 11, 2015

mback2k pushed a commit to mback2k/libssh2 that referenced this issue Mar 14, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment