]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Use poll, if indicated to do so, in the ast_poll2 implementation.
authorTilghman Lesher <tilghman@meg.abyt.es>
Tue, 7 Sep 2010 19:04:50 +0000 (19:04 +0000)
committerTilghman Lesher <tilghman@meg.abyt.es>
Tue, 7 Sep 2010 19:04:50 +0000 (19:04 +0000)
This fixes the unit tests on FreeBSD 8.0.

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@285266 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/poll.c

index 87cbd28ce05e3517b49234d0f62a5b8d3383e467..d9151c01669ee8a902ffbbe1d3f3854265d63870 100644 (file)
@@ -94,7 +94,7 @@
                                 Private Functions
 \*---------------------------------------------------------------------------*/
 
-#if defined(AST_POLL_COMPAT) || !defined(HAVE_PPOLL)
+#if defined(AST_POLL_COMPAT)
 static int map_poll_spec(struct pollfd *pArray, unsigned long n_fds,
                ast_fdset *pReadSet, ast_fdset *pWriteSet, ast_fdset *pExceptSet)
 {
@@ -268,10 +268,14 @@ int ast_internal_poll(struct pollfd *pArray, unsigned long n_fds, int timeout)
 
 int ast_poll2(struct pollfd *pArray, unsigned long n_fds, struct timeval *tv)
 {
-#ifdef HAVE_PPOLL
+#if !defined(AST_POLL_COMPAT)
        struct timeval start = ast_tvnow();
+#if defined(HAVE_PPOLL)
        struct timespec ts = { tv ? tv->tv_sec : 0, tv ? tv->tv_usec * 1000 : 0 };
        int res = ppoll(pArray, n_fds, tv ? &ts : NULL, NULL);
+#else
+       int res = poll(pArray, n_fds, tv ? tv->tv_sec * 1000 + tv->tv_usec / 1000 : -1);
+#endif
        struct timeval after = ast_tvnow();
        if (res > 0 && tv && ast_tvdiff_ms(ast_tvadd(*tv, start), after) > 0) {
                *tv = ast_tvsub(*tv, ast_tvsub(after, start));