then
AC_CHECK_HEADERS([sys/select.h])
- mutt_save_LIBS="$LIBS"
- LIBS=
- AC_SEARCH_LIBS([clock_gettime], [rt],
- MUTTLIBS="$MUTTLIBS $LIBS",
- AC_MSG_ERROR([Unable to find clock_gettime function]))
- LIBS="$mutt_save_LIBS"
-
AC_MSG_CHECKING([for socklen_t])
AC_EGREP_HEADER(socklen_t, sys/socket.h, AC_MSG_RESULT([yes]),
AC_MSG_RESULT([no])
int raw_socket_poll (CONNECTION* conn, time_t wait_secs)
{
fd_set rfds;
- struct timeval tv;
- struct timespec pre_t, post_t;
- time_t sleep_secs;
+ unsigned long wait_millis, post_t_millis;
+ struct timeval tv, pre_t, post_t;
int rv;
if (conn->fd < 0)
return -1;
+ wait_millis = wait_secs * 1000UL;
+
FOREVER
{
- tv.tv_sec = wait_secs;
- tv.tv_usec = 0;
+ tv.tv_sec = wait_millis / 1000;
+ tv.tv_usec = (wait_millis % 1000) * 1000;
FD_ZERO (&rfds);
FD_SET (conn->fd, &rfds);
- clock_gettime (CLOCK_MONOTONIC, &pre_t);
+ gettimeofday (&pre_t, NULL);
rv = select (conn->fd + 1, &rfds, NULL, NULL, &tv);
- clock_gettime (CLOCK_MONOTONIC, &post_t);
+ gettimeofday (&post_t, NULL);
if (rv > 0 ||
(rv < 0 && errno != EINTR))
if (SigInt)
mutt_query_exit ();
- sleep_secs = post_t.tv_sec - pre_t.tv_sec;
- if (wait_secs <= sleep_secs)
+ wait_millis += (pre_t.tv_sec * 1000UL) + (pre_t.tv_usec / 1000);
+ post_t_millis = (post_t.tv_sec * 1000UL) + (post_t.tv_usec / 1000);
+ if (wait_millis <= post_t_millis)
return 0;
- wait_secs -= sleep_secs;
+ wait_millis -= post_t_millis;
}
}