check for a fine poll() before it is used to sleep subsecond
This commit is contained in:
parent
6f252f4704
commit
a7b99fc463
15
CHANGES
15
CHANGES
@ -6,6 +6,21 @@
|
|||||||
|
|
||||||
Changelog
|
Changelog
|
||||||
|
|
||||||
|
Daniel (27 June 2004)
|
||||||
|
- Based on Bob's bug report #979480, I wrote a configure check that checks if
|
||||||
|
poll() can be used to wait on NULL as otherwise select() should be used to
|
||||||
|
do it. The select() usage was also fixed according to his report.
|
||||||
|
|
||||||
|
Mac OS X 10.3 says "poll() functionality for Mac OS X is implemented via an
|
||||||
|
emulation layer on top of select(), not in the kernel directly. It is
|
||||||
|
recommended that programs running under OS X 10.3 prefer select() over
|
||||||
|
poll(). Configure scripts should look for the _POLL_EMUL_H_ define (instead
|
||||||
|
of _POLL_H_ or _SYS_POLL_H_) and avoid implementations where poll is not
|
||||||
|
implemented in the kernel."
|
||||||
|
|
||||||
|
Yes, we can probably use select() on most platforms but today I prefered to
|
||||||
|
leave the code unaltered.
|
||||||
|
|
||||||
Daniel (24 June 2004)
|
Daniel (24 June 2004)
|
||||||
- The standard curl_version() string now only includes version info about
|
- The standard curl_version() string now only includes version info about
|
||||||
involved libraries and not about particular features. Thus it will no longer
|
involved libraries and not about particular features. Thus it will no longer
|
||||||
|
25
configure.ac
25
configure.ac
@ -1201,6 +1201,31 @@ if test "$ac_cv_func_sigsetjmp" != "yes"; then
|
|||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
dnl poll() might be badly emulated, as in Mac OS X 10.3 (and other BSDs?) and
|
||||||
|
dnl to find out we make an extra check here!
|
||||||
|
if test "$ac_cv_func_poll" = "yes"; then
|
||||||
|
AC_MSG_CHECKING([if poll works with NULL inputs])
|
||||||
|
AC_RUN_IFELSE([
|
||||||
|
#ifdef HAVE_SYS_POLL_H
|
||||||
|
#include <sys/poll.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
/* make this return 0 == timeout since there's nothing to read from */
|
||||||
|
return poll((void *)0, 0, 10 /*ms*/);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
AC_DEFINE(HAVE_POLL_FINE, 1, [If you have a fine poll]),
|
||||||
|
AC_MSG_RESULT(no),
|
||||||
|
AC_MSG_RESULT(cross-compiling assumes yes)
|
||||||
|
AC_DEFINE(HAVE_POLL_FINE, 1, [If you have a fine poll])
|
||||||
|
) dnl end of AC_RUN_IFELSE
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
AC_PATH_PROG( PERL, perl, ,
|
AC_PATH_PROG( PERL, perl, ,
|
||||||
$PATH:/usr/local/bin/perl:/usr/bin/:/usr/local/bin )
|
$PATH:/usr/local/bin/perl:/usr/bin/:/usr/local/bin )
|
||||||
AC_SUBST(PERL)
|
AC_SUBST(PERL)
|
||||||
|
@ -35,6 +35,9 @@
|
|||||||
/* Define if you have the `poll' function. */
|
/* Define if you have the `poll' function. */
|
||||||
#undef HAVE_POLL
|
#undef HAVE_POLL
|
||||||
|
|
||||||
|
/* Define if you have a good `poll' function that can wait on NULL. */
|
||||||
|
#undef HAVE_POLL_FINE
|
||||||
|
|
||||||
/* Define if you can write to argc[] strings */
|
/* Define if you can write to argc[] strings */
|
||||||
#undef HAVE_WRITABLE_ARGV
|
#undef HAVE_WRITABLE_ARGV
|
||||||
|
|
||||||
|
@ -2243,7 +2243,7 @@ static void parseconfig(const char *filename,
|
|||||||
|
|
||||||
static void go_sleep(long ms)
|
static void go_sleep(long ms)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_POLL
|
#ifdef HAVE_POLL_FINE
|
||||||
/* portable subsecond "sleep" */
|
/* portable subsecond "sleep" */
|
||||||
poll((void *)0, 0, ms);
|
poll((void *)0, 0, ms);
|
||||||
#else
|
#else
|
||||||
@ -2259,7 +2259,7 @@ static void go_sleep(long ms)
|
|||||||
struct timeval timeout;
|
struct timeval timeout;
|
||||||
|
|
||||||
timeout.tv_sec = ms/1000;
|
timeout.tv_sec = ms/1000;
|
||||||
ms -= ms/1000;
|
ms = ms%1000;
|
||||||
timeout.tv_usec = ms * 1000;
|
timeout.tv_usec = ms * 1000;
|
||||||
|
|
||||||
select(0, NULL, NULL, NULL, &timeout);
|
select(0, NULL, NULL, NULL, &timeout);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user