1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-11-23 01:22:37 +03:00

gettimeofday: fix name space pollution

For systems without its own gettimeofday() implementation, we still must
not provide one outside our namespace.

Reported by: Bill Segall
This commit is contained in:
Daniel Stenberg
2011-08-05 23:46:12 +02:00
parent 49453c9ae2
commit 79f48e4881
3 changed files with 26 additions and 15 deletions

View File

@@ -56,6 +56,7 @@
#include "session.h"
#include "channel.h"
#include "mac.h"
#include "misc.h"
/* libssh2_default_alloc
*/
@@ -1573,13 +1574,13 @@ libssh2_poll(LIBSSH2_POLLFD * fds, unsigned int nfds, long timeout)
}
#ifdef HAVE_POLL
#ifdef HAVE_GETTIMEOFDAY
#ifdef HAVE_LIBSSH2_GETTIMEOFDAY
{
struct timeval tv_begin, tv_end;
gettimeofday((struct timeval *) &tv_begin, NULL);
_libssh2_gettimeofday((struct timeval *) &tv_begin, NULL);
sysret = poll(sockets, nfds, timeout_remaining);
gettimeofday((struct timeval *) &tv_end, NULL);
_libssh2_gettimeofday((struct timeval *) &tv_end, NULL);
timeout_remaining -= (tv_end.tv_sec - tv_begin.tv_sec) * 1000;
timeout_remaining -= (tv_end.tv_usec - tv_begin.tv_usec) / 1000;
}
@@ -1633,13 +1634,13 @@ libssh2_poll(LIBSSH2_POLLFD * fds, unsigned int nfds, long timeout)
#elif defined(HAVE_SELECT)
tv.tv_sec = timeout_remaining / 1000;
tv.tv_usec = (timeout_remaining % 1000) * 1000;
#ifdef HAVE_GETTIMEOFDAY
#ifdef HAVE_LIBSSH2_GETTIMEOFDAY
{
struct timeval tv_begin, tv_end;
gettimeofday((struct timeval *) &tv_begin, NULL);
_libssh2_gettimeofday((struct timeval *) &tv_begin, NULL);
sysret = select(maxfd+1, &rfds, &wfds, NULL, &tv);
gettimeofday((struct timeval *) &tv_end, NULL);
_libssh2_gettimeofday((struct timeval *) &tv_end, NULL);
timeout_remaining -= (tv_end.tv_sec - tv_begin.tv_sec) * 1000;
timeout_remaining -= (tv_end.tv_usec - tv_begin.tv_usec) / 1000;