diff options
author | ylavic <ylavic@13f79535-47bb-0310-9956-ffa450edef68> | 2023-03-21 15:44:06 +0000 |
---|---|---|
committer | ylavic <ylavic@13f79535-47bb-0310-9956-ffa450edef68> | 2023-03-21 15:44:06 +0000 |
commit | e6c4a8b4b055eafe93aa297048696164fe6ceebc (patch) | |
tree | 1b65a144d4996261f61cf2b34ca1899ba1f6db32 /configure.in | |
parent | 50f146723063642b158d9638af61bc470cc97f45 (diff) | |
download | libapr-e6c4a8b4b055eafe93aa297048696164fe6ceebc.tar.gz |
tests: check whether epoll_wait() timeout is reliable and adjust justsleep().
* configure.in:
Small epoll_wait() loop to check timeout reliability and set
HAVE_EPOLL_WAIT_RELIABLE_TIMEOUT.
* test/testpoll.c(justsleep):
Allow some jiffy is !HAVE_EPOLL_WAIT_RELIABLE_TIMEOUT.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1908616 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'configure.in')
-rw-r--r-- | configure.in | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/configure.in b/configure.in index 9e828ec6a..2225cb0a4 100644 --- a/configure.in +++ b/configure.in @@ -1099,7 +1099,7 @@ AC_CACHE_CHECK([for epoll support], [apr_cv_epoll], #include <sys/epoll.h> #include <unistd.h> -int main() +int main(int argc, const char *argv[]) { return epoll_create(5) == -1; }], [apr_cv_epoll=yes], [apr_cv_epoll=no], [apr_cv_epoll=no])]) @@ -1115,7 +1115,7 @@ AC_CACHE_CHECK([for epoll_create1 support], [apr_cv_epoll_create1], #include <sys/epoll.h> #include <unistd.h> -int main() +int main(int argc, const char *argv[]) { return epoll_create1(0) == -1; }], [apr_cv_epoll_create1=yes], [apr_cv_epoll_create1=no], [apr_cv_epoll_create1=no])]) @@ -1124,6 +1124,47 @@ if test "$apr_cv_epoll_create1" = "yes"; then AC_DEFINE([HAVE_EPOLL_CREATE1], 1, [Define if epoll_create1 function is supported]) fi +# check if epoll_wait() timeout is a reliable as min min +AC_CACHE_CHECK([whether epoll_wait has a reliable timeout (min)], + [apr_cv_epoll_wait_has_reliable_timeout], +[AC_TRY_RUN([ +#include <unistd.h> +#include <sys/epoll.h> +#include <sys/time.h> /* for gettimeofday */ + +#define TV2US(tv) ((long long)(tv).tv_sec * 1000000 + (tv).tv_usec) + +int main(int argc, const char *argv[]) +{ + int ret = 0, fd, i; + struct epoll_event events; + struct timeval t1, t2; + +#ifdef HAVE_EPOLL_CREATE1 + fd = epoll_create1(0); +#else + fd = epoll_create(1); +#endif + if (fd < 0) { + return 1; + } + for (i = 0; i < 10; ++i) { + (void)gettimeofday(&t1, NULL); + (void)epoll_wait(fd, &events, 1, 100); /* ms */ + (void)gettimeofday(&t2, NULL); + ret |= (TV2US(t2) - TV2US(t1)) < 100000; /* us */ + } + close(fd); + return ret; +}], [apr_cv_epoll_wait_has_reliable_timeout=yes], + [apr_cv_epoll_wait_has_reliable_timeout=no], + [apr_cv_epoll_wait_has_reliable_timeout=no])]) + +if test "$apr_cv_epoll_wait_has_reliable_timeout" = "yes"; then + AC_DEFINE([HAVE_EPOLL_WAIT_RELIABLE_TIMEOUT], 1, + [Define if epoll_wait has a reliable timeout (min)]) +fi + # Check for z/OS async i/o support. AC_CACHE_CHECK([for asio -> message queue support], [apr_cv_aio_msgq], [AC_TRY_RUN([ |