]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Fix cases where the internal poll() was not being used when it needed to be.
authorRussell Bryant <russell@russellbryant.com>
Wed, 18 Mar 2009 02:09:13 +0000 (02:09 +0000)
committerRussell Bryant <russell@russellbryant.com>
Wed, 18 Mar 2009 02:09:13 +0000 (02:09 +0000)
We have seen a number of problems caused by poll() not working properly on
Mac OSX.  If you search around, you'll find a number of references to using
select() instead of poll() to work around these issues.  In Asterisk, we've
had poll.c which implements poll() using select() internally.  However, we
were still getting reports of problems.

vadim investigated a bit and realized that at least on his system, even
though we were compiling in poll.o, the system poll() was still being used.
So, the primary purpose of this patch is to ensure that we're using the
internal poll() when we want it to be used.

The changes are:

1) Remove logic for when internal poll should be used from the Makefile.
   Instead, put it in the configure script.  The logic in the configure
   script is the same as it was in the Makefile.  Ideally, we would have
   a functionality test for the problem, but that's not actually possible,
   since we would have to be able to run an application on the _target_
   system to test poll() behavior.

2) Always include poll.o in the build, but it will be empty if AST_POLL_COMPAT
   is not defined.

3) Change uses of poll() throughout the source tree to ast_poll().  I feel
   that it is good practice to give the API call a new name when we are
   changing its behavior and not using the system version directly in all cases.
   So, normally, ast_poll() is just redefined to poll().  On systems where
   AST_POLL_COMPAT is defined, ast_poll() is redefined to ast_internal_poll().

4) Change poll() in main/poll.c to be ast_internal_poll().

It's worth noting that any code that still uses poll() directly will work fine
(if they worked fine before).  So, for example, out of tree modules that are
using poll() will not stop working or anything.  However, for modules to work
properly on Mac OSX, ast_poll() needs to be used.

(closes issue #13404)
Reported by: agalbraith
Tested by: russell, vadim

http://reviewboard.digium.com/r/198/

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

18 files changed:
apps/app_mp3.c
apps/app_nbscat.c
channels/chan_alsa.c
channels/chan_skinny.c
configure
configure.ac
include/asterisk/autoconfig.h.in
include/asterisk/channel.h
include/asterisk/io.h
include/asterisk/poll-compat.h
main/Makefile
main/asterisk.c
main/channel.c
main/io.c
main/manager.c
main/poll.c
main/utils.c
res/res_agi.c

index 7cacc1e77bd8208f8ce9abf1f78b56dc8288e7ae..1f550a1ddde7a7f277aecb9ecadb454171b681a9 100644 (file)
@@ -131,7 +131,7 @@ static int timed_read(int fd, void *data, int datalen, int timeout)
        struct pollfd fds[1];
        fds[0].fd = fd;
        fds[0].events = POLLIN;
-       res = poll(fds, 1, timeout);
+       res = ast_poll(fds, 1, timeout);
        if (res < 1) {
                ast_log(LOG_NOTICE, "Poll timed out/errored out with %d\n", res);
                return -1;
index d9a2dd4026f7bf43cd77304e0f65c2ac573b3cf3..841d8a37557e1ee96e75a1f21882c5ee2631bac1 100644 (file)
@@ -123,7 +123,7 @@ static int timed_read(int fd, void *data, int datalen)
        struct pollfd fds[1];
        fds[0].fd = fd;
        fds[0].events = POLLIN;
-       res = poll(fds, 1, 2000);
+       res = ast_poll(fds, 1, 2000);
        if (res < 1) {
                ast_log(LOG_NOTICE, "Selected timed out/errored out with %d\n", res);
                return -1;
index 03db26b6a2e7ebc46122b6b2a19f7c58440b4c13..3a9a47208c47d38fa9f04c560fed4a93c6a08c76 100644 (file)
@@ -62,6 +62,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #include "asterisk/stringfields.h"
 #include "asterisk/abstract_jb.h"
 #include "asterisk/musiconhold.h"
+#include "asterisk/poll-compat.h"
 
 #include "busy_tone.h"
 #include "ring_tone.h"
index 657163398b326521679daf6f8580ec596a7d9c3f..983dbf847391e7e328af1d799aa3ca184ef1793c 100644 (file)
@@ -4441,7 +4441,7 @@ static int get_input(struct skinnysession *s)
        fds[0].fd = s->fd;
        fds[0].events = POLLIN;
        fds[0].revents = 0;
-       res = poll(fds, 1, (keep_alive * 1100)); /* If nothing has happen, client is dead */
+       res = ast_poll(fds, 1, (keep_alive * 1100)); /* If nothing has happen, client is dead */
                                                 /* we add 10% to the keep_alive to deal */
                                                 /* with network delays, etc */
        if (res < 0) {
index 30a3f98bb70ab731ac7b7bc7627260e11443565f..c6db56a66b92625741cd98af06fc2343023a2996 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.ac Revision: 180941 .
+# From configure.ac Revision: 182213 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.61 for asterisk 1.4.
 #
@@ -3960,6 +3960,13 @@ case "${host_os}" in
      ac_default_prefix=/usr/local
      CPPFLAGS=-I/usr/local/include
      LDFLAGS=-L/usr/local/lib
+     ;;
+     darwin*)
+
+cat >>confdefs.h <<\_ACEOF
+#define AST_POLL_COMPAT 1
+_ACEOF
+
      ;;
      *)
      ac_default_prefix=/usr
@@ -9918,6 +9925,148 @@ fi
 done
 
 
+if test "${ac_cv_header_sys_poll_h+set}" = set; then
+  { echo "$as_me:$LINENO: checking for sys/poll.h" >&5
+echo $ECHO_N "checking for sys/poll.h... $ECHO_C" >&6; }
+if test "${ac_cv_header_sys_poll_h+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_header_sys_poll_h" >&5
+echo "${ECHO_T}$ac_cv_header_sys_poll_h" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking sys/poll.h usability" >&5
+echo $ECHO_N "checking sys/poll.h usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <sys/poll.h>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking sys/poll.h presence" >&5
+echo $ECHO_N "checking sys/poll.h presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <sys/poll.h>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+        test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: sys/poll.h: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: sys/poll.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: sys/poll.h: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: sys/poll.h: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: sys/poll.h: present but cannot be compiled" >&5
+echo "$as_me: WARNING: sys/poll.h: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: sys/poll.h:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: sys/poll.h:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: sys/poll.h: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: sys/poll.h: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: sys/poll.h:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: sys/poll.h:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: sys/poll.h: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: sys/poll.h: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: sys/poll.h: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: sys/poll.h: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## ------------------------------- ##
+## Report this to www.asterisk.org ##
+## ------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for sys/poll.h" >&5
+echo $ECHO_N "checking for sys/poll.h... $ECHO_C" >&6; }
+if test "${ac_cv_header_sys_poll_h+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_header_sys_poll_h=$ac_header_preproc
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_header_sys_poll_h" >&5
+echo "${ECHO_T}$ac_cv_header_sys_poll_h" >&6; }
+
+fi
+if test $ac_cv_header_sys_poll_h = yes; then
+  :
+else
+
+cat >>confdefs.h <<\_ACEOF
+#define AST_POLL_COMPAT 1
+_ACEOF
+
+fi
+
+
+
 # Check whether --enable-largefile was given.
 if test "${enable_largefile+set}" = set; then
   enableval=$enable_largefile;
index 8282f9f5f5839771869465f5b1f34ea45a761225..f072359ccc4b853379a90fe15f97689152f9441b 100644 (file)
@@ -25,6 +25,9 @@ case "${host_os}" in
      CPPFLAGS=-I/usr/local/include
      LDFLAGS=-L/usr/local/lib
      ;;
+     darwin*)
+     AC_DEFINE([AST_POLL_COMPAT], 1, [Define to 1 if internal poll should be used.])
+     ;;
      *)
      ac_default_prefix=/usr
      if test ${prefix} = '/usr' || test ${prefix} = 'NONE'; then
@@ -226,6 +229,10 @@ AC_HEADER_STDC
 AC_HEADER_SYS_WAIT
 AC_CHECK_HEADERS([arpa/inet.h fcntl.h inttypes.h libintl.h limits.h locale.h malloc.h netdb.h netinet/in.h stddef.h stdint.h stdlib.h string.h strings.h sys/file.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h syslog.h termios.h unistd.h utime.h arpa/nameser.h sys/io.h])
 
+AC_CHECK_HEADER([sys/poll.h],
+        [],
+     AC_DEFINE([AST_POLL_COMPAT], 1, [Define to 1 if internal poll should be used.]))
+
 AC_SYS_LARGEFILE
 
 # Checks for typedefs, structures, and compiler characteristics.
index b05c0ff32c548a275cde2c3e5ff7ae93bcbd534d..1c44abb3bdac25a945340935ea257b4bc22f5ca0 100644 (file)
@@ -7,6 +7,9 @@
 
 
 
+/* Define to 1 if internal poll should be used. */
+#undef AST_POLL_COMPAT
+
 /* Define to 1 if the `closedir' function returns void instead of `int'. */
 #undef CLOSEDIR_VOID
 
index f7718684b8ac01c606ac6d03dc3f25eb046914dd..29713b8ca0401e4177fb9890f971eec335081653 100644 (file)
 #include "asterisk/abstract_jb.h"
 
 #include <unistd.h>
-#ifdef POLLCOMPAT 
+
 #include "asterisk/poll-compat.h"
-#else
-#include <sys/poll.h>
-#endif
 
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
index 66ebceea02f466443bad34c9af4d442f33381109..d0e337204480f1daaddd97fcff6d7ff0f862f028 100644 (file)
 #ifndef _ASTERISK_IO_H
 #define _ASTERISK_IO_H
 
-#ifdef POLLCOMPAT
 #include "asterisk/poll-compat.h"
-#else
-#include <sys/poll.h>          /* For POLL* constants */
-#endif
 
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
index 5f795a894131d6967ab102dbf4aa4a47764f4e29..1156e694bdcbb5a74e4cb94d41bc2ebc9c8c57cc 100644 (file)
        original.
 \*---------------------------------------------------------------------------*/
 
-#ifndef _POLL_EMUL_H_
-#define _POLL_EMUL_H_
+#ifndef __AST_POLL_COMPAT_H
+#define __AST_POLL_COMPAT_H
+
+#ifndef AST_POLL_COMPAT
+
+#include <sys/poll.h>
+
+#define ast_poll(a, b, c) poll(a, b, c)
+
+#else /* AST_POLL_COMPAT */
 
 #define POLLIN         0x01
 #define POLLPRI                0x02
 #define POLLHUP                0x10
 #define POLLNVAL       0x20
 
-struct pollfd
-{
+struct pollfd {
     int     fd;
     short   events;
     short   revents;
 };
 
 #ifdef __cplusplus
-extern "C"
-{
+extern "C" {
 #endif
 
-#if (__STDC__ > 0) || defined(__cplusplus)
-extern int poll (struct pollfd *pArray, unsigned long n_fds, int timeout);
-#else
-extern int poll();
-#endif
+#define ast_poll(a, b, c) ast_internal_poll(a, b, c)
+
+int ast_internal_poll(struct pollfd *pArray, unsigned long n_fds, int timeout);
 
 #ifdef __cplusplus
 }
 #endif
 
-#endif /* _POLL_EMUL_H_ */
+#endif /* AST_POLL_COMPAT */
+
+#endif /* __AST_POLL_COMPAT_H */
index 0b83191e06fe24bac0603865f91a45288a52e4ef..38d49f34c2868351b3ccca37325669571f844bf3 100644 (file)
@@ -27,7 +27,7 @@ OBJS= io.o sched.o logger.o frame.o loader.o config.o channel.o \
        netsock.o slinfactory.o ast_expr2.o ast_expr2f.o \
        cryptostub.o sha1.o http.o fixedjitterbuf.o abstract_jb.o \
        strcompat.o threadstorage.o dial.o astobj2.o global_datastores.o \
-       audiohook.o
+       audiohook.o poll.o
 
 # we need to link in the objects statically, not as a library, because
 # otherwise modules will not have them available if none of the static
@@ -38,16 +38,6 @@ OBJS+=stdtime/localtime.o
 # by a module.
 OBJS+=say.o
 
-ifneq ($(findstring darwin,$(OSARCH)),)
-  OBJS+=poll.o
-  ASTCFLAGS+=-DPOLLCOMPAT
-else
-  ifeq ($(wildcard /usr/include/sys/poll.h),)
-    OBJS+=poll.o
-    ASTCFLAGS+=-DPOLLCOMPAT
-  endif
-endif
-
 ifneq ($(findstring $(OSARCH), linux-gnu uclinux linux-uclibc linux-gnueabi ),)
   ifneq ($(findstring LOADABLE_MODULES,$(MENUSELECT_CFLAGS)),)
   AST_LIBS+=-ldl
index 9d4c92cb03d70cd832d1e93a9385fc73be12d1c4..2cabfc272bb2526bcd70219013fa45ee098a70a6 100644 (file)
@@ -123,6 +123,7 @@ int daemon(int, int);  /* defined in libresolv of all places */
 #include "asterisk/linkedlists.h"
 #include "asterisk/devicestate.h"
 #include "asterisk/module.h"
+#include "asterisk/poll-compat.h"
 
 #include "asterisk/doxyref.h"          /* Doxygen documentation */
 
@@ -955,7 +956,7 @@ static void *netconsole(void *vconsole)
                fds[1].events = POLLIN;
                fds[1].revents = 0;
 
-               res = poll(fds, 2, -1);
+               res = ast_poll(fds, 2, -1);
                if (res < 0) {
                        if (errno != EINTR)
                                ast_log(LOG_WARNING, "poll returned < 0: %s\n", strerror(errno));
@@ -1006,7 +1007,7 @@ static void *listener(void *unused)
                        return NULL;
                fds[0].fd = ast_socket;
                fds[0].events = POLLIN;
-               s = poll(fds, 1, -1);
+               s = ast_poll(fds, 1, -1);
                pthread_testcancel();
                if (s < 0) {
                        if (errno != EINTR)
@@ -1784,7 +1785,7 @@ static int ast_el_read_char(EditLine *el, char *cp)
                        fds[1].events = POLLIN;
                        max++;
                }
-               res = poll(fds, max, -1);
+               res = ast_poll(fds, max, -1);
                if (res < 0) {
                        if (sig_flags.need_quit)
                                break;
@@ -2379,7 +2380,7 @@ static void ast_remotecontrol(char *data)
                fds.fd = ast_consock;
                fds.events = POLLIN;
                fds.revents = 0;
-               while (poll(&fds, 1, 500) > 0) {
+               while (ast_poll(&fds, 1, 500) > 0) {
                        char buf[512] = "", *curline = buf, *nextline;
                        int not_written = 1;
 
@@ -2668,7 +2669,7 @@ static void *monitor_sig_flags(void *unused)
        for (;;) {
                struct pollfd p = { sig_alert_pipe[0], POLLIN, 0 };
                int a;
-               poll(&p, 1, -1);
+               ast_poll(&p, 1, -1);
                if (sig_flags.need_reload) {
                        sig_flags.need_reload = 0;
                        ast_module_reload(NULL);
index 4759421637f3785f342822f1bcb0151a69fae733..5d3eb9b358017c926d0db0da3d425139af06edc8 100644 (file)
@@ -1754,12 +1754,12 @@ struct ast_channel *ast_waitfor_nandfds(struct ast_channel **c, int n, int *fds,
                        int kbrms = rms;
                        if (kbrms > 600000)
                                kbrms = 600000;
-                       res = poll(pfds, max, kbrms);
+                       res = ast_poll(pfds, max, kbrms);
                        if (!res)
                                rms -= kbrms;
                } while (!res && (rms > 0));
        } else {
-               res = poll(pfds, max, rms);
+               res = ast_poll(pfds, max, rms);
        }
        for (x=0; x<n; x++)
                ast_clear_flag(c[x], AST_FLAG_BLOCKING);
index ced692180a8ba5a12199b240375b0ea970be478b..7947cdedc7d2a66af718d607227466f46a9faa40 100644 (file)
--- a/main/io.c
+++ b/main/io.c
@@ -263,7 +263,7 @@ int ast_io_wait(struct io_context *ioc, int howlong)
        int x;
        int origcnt;
        DEBUG(ast_log(LOG_DEBUG, "ast_io_wait()\n"));
-       res = poll(ioc->fds, ioc->fdcnt, howlong);
+       res = ast_poll(ioc->fds, ioc->fdcnt, howlong);
        if (res > 0) {
                /*
                 * At least one event
index 8b795a86f4cabfdc7cece0994abc25b5c89e8521..e88af7f98a0845f6a8ab987006a783b654971ad7 100644 (file)
@@ -2287,7 +2287,7 @@ static int get_input(struct mansession *s, char *output)
                s->waiting_thread = pthread_self();
                ast_mutex_unlock(&s->__lock);
 
-               res = poll(fds, 1, -1);
+               res = ast_poll(fds, 1, -1);
 
                ast_mutex_lock(&s->__lock);
                s->waiting_thread = AST_PTHREADT_NULL;
@@ -2431,7 +2431,7 @@ static void *accept_thread(void *ignore)
                pfds[0].events = POLLIN;
                /* Wait for something to happen, but timeout every few seconds so
                   we can ditch any old manager sessions */
-               if (poll(pfds, 1, 5000) < 1)
+               if (ast_poll(pfds, 1, 5000) < 1)
                        continue;
                as = accept(asock, (struct sockaddr *)&sin, &sinlen);
                if (as < 0) {
index c053ba01504af07b4716f9c381f7cdd1542b0ead..aba6e593e34d6308486945738e72beb4a4daafed 100644 (file)
@@ -71,6 +71,8 @@
                                 Includes
 \*---------------------------------------------------------------------------*/
 
+#include "asterisk.h"
+
 #include <unistd.h>                         /* standard Unix definitions */
 #include <sys/types.h>                       /* system types */
 #include <sys/time.h>                        /* time definitions */
@@ -79,6 +81,8 @@
 
 #include "asterisk/poll-compat.h"                            /* this package */
 
+#ifdef AST_POLL_COMPAT
+
 /*---------------------------------------------------------------------------*\
                                  Macros
 \*---------------------------------------------------------------------------*/
@@ -87,7 +91,6 @@
 #define MAX(a,b)       ((a) > (b) ? (a) : (b))
 #endif
 
-\f
 /*---------------------------------------------------------------------------*\
                             Private Functions
 \*---------------------------------------------------------------------------*/
@@ -209,7 +212,7 @@ static struct timeval *map_timeout
 
     return pResult;
 }
-\f
+
 static void map_select_results
 #if __STDC__ > 0
                         (struct pollfd *pArray,
@@ -251,22 +254,12 @@ static void map_select_results
 
     return;
 }
-\f
+
 /*---------------------------------------------------------------------------*\
                             Public Functions
 \*---------------------------------------------------------------------------*/
 
-int poll
-
-#if __STDC__ > 0
-       (struct pollfd *pArray, unsigned long n_fds, int timeout)
-#else
-       (pArray, n_fds, timeout)
-        struct        pollfd *pArray;
-        unsigned long n_fds;
-        int           timeout;
-#endif
-
+int ast_internal_poll(struct pollfd *pArray, unsigned long n_fds, int timeout)
 {
     fd_set  read_descs;                          /* input file descs */
     fd_set  write_descs;                         /* output file descs */
@@ -304,3 +297,5 @@ int poll
 
     return ready_descriptors;
 }
+
+#endif /* AST_POLL_COMPAT */
index 0b96d8b88c18b68d7522cba327989e33c38bcc9f..6ff44dd48e180b2c336245761139227b0db1d3f7 100644 (file)
@@ -916,7 +916,7 @@ int ast_wait_for_input(int fd, int ms)
        memset(pfd, 0, sizeof(pfd));
        pfd[0].fd = fd;
        pfd[0].events = POLLIN|POLLPRI;
-       return poll(pfd, 1, ms);
+       return ast_poll(pfd, 1, ms);
 }
 
 int ast_carefulwrite(int fd, char *s, int len, int timeoutms) 
@@ -932,7 +932,7 @@ int ast_carefulwrite(int fd, char *s, int len, int timeoutms)
                };
 
                /* poll() until the fd is writable without blocking */
-               while ((res = poll(&pfd, 1, timeoutms - elapsed)) <= 0) {
+               while ((res = ast_poll(&pfd, 1, timeoutms - elapsed)) <= 0) {
                        if (res == 0) {
                                /* timed out. */
                                ast_log(LOG_NOTICE, "Timed out trying to write\n");
index 35b29d52fac339c06f017880c39157216db70f3f..15ecaa516c61f07a55262a618b5cc9067495649f 100644 (file)
@@ -221,7 +221,7 @@ static enum agi_result launch_netscript(char *agiurl, char *argv[], int *fds, in
 
        pfds[0].fd = s;
        pfds[0].events = POLLOUT;
-       while ((res = poll(pfds, 1, MAX_AGI_CONNECT)) != 1) {
+       while ((res = ast_poll(pfds, 1, MAX_AGI_CONNECT)) != 1) {
                if (errno != EINTR) {
                        if (!res) {
                                ast_log(LOG_WARNING, "FastAGI connection to '%s' timed out after MAX_AGI_CONNECT (%d) milliseconds.\n",
@@ -2269,7 +2269,7 @@ static void *shaun_of_the_dead(void *data)
                }
                pthread_testcancel();
                /* Wait for 60 seconds, without engaging in a busy loop. */
-               poll(NULL, 0, 60000);
+               ast_poll(NULL, 0, 60000);
        }
        return NULL;
 }