diff --git a/apps/app_mp3.c b/apps/app_mp3.c
index 688be6a00015e8150d1039f8eb00994e5bfe75a3..41e27f9b3651e5cd8dcb1836f2697c47a3f917fa 100644
--- a/apps/app_mp3.c
+++ b/apps/app_mp3.c
@@ -108,7 +108,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;
diff --git a/apps/app_nbscat.c b/apps/app_nbscat.c
index dd071ef0e649078247e567dc9d00a49e79e0fdc4..112e01297f2735c2383611264b0c062d617d5a68 100644
--- a/apps/app_nbscat.c
+++ b/apps/app_nbscat.c
@@ -96,7 +96,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;
diff --git a/channels/chan_alsa.c b/channels/chan_alsa.c
index 0de29004246b976489e6ca18c505a0884b8a84a5..16efefbbf2a5ad2c5f78ee5680b932b24a691998 100644
--- a/channels/chan_alsa.c
+++ b/channels/chan_alsa.c
@@ -55,6 +55,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #include "asterisk/stringfields.h"
 #include "asterisk/abstract_jb.h"
 #include "asterisk/musiconhold.h"
+#include "asterisk/poll-compat.h"
 
 /*! Global jitterbuffer configuration - by default, jb is disabled */
 static struct ast_jb_conf default_jbconf = {
diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c
index aba614d60c9db0e7276347a51c6cd2b19b26ba72..e8330fa824991efab4b6fd96f1e4ce98b92ddb85 100644
--- a/channels/chan_skinny.c
+++ b/channels/chan_skinny.c
@@ -6248,7 +6248,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) {
diff --git a/configure b/configure
index f27257f41f37a55e9f644a4bc0b79a2664414a46..f3936a0bb9c1b532ce66659be8ee1a07125a4562 100755
--- a/configure
+++ b/configure
@@ -4104,6 +4104,13 @@ case "${host_os}" in
      fi
      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
@@ -11239,6 +11246,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;
diff --git a/configure.ac b/configure.ac
index 8e4cad571188cb99b02e8f8e6f0a2855b8965dce..d372f045ab846b8371ea8b93202ca43e31267693 100644
--- a/configure.ac
+++ b/configure.ac
@@ -44,6 +44,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
@@ -304,6 +307,10 @@ AC_CHECK_HEADERS([arpa/inet.h fcntl.h inttypes.h libintl.h limits.h locale.h mal
 
 AC_CHECK_HEADERS([winsock.h winsock2.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.
diff --git a/include/asterisk/autoconfig.h.in b/include/asterisk/autoconfig.h.in
index 38d3e8de5b9b0c4d1d081816f5fad5d93424255d..4961c308cd162d912e13a1b4f7d98f69071ea1d5 100644
--- a/include/asterisk/autoconfig.h.in
+++ b/include/asterisk/autoconfig.h.in
@@ -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
 
diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h
index eff55ca354e99641ad7c5bbac13b9e7909b4dc3d..d601bb72c264237fff3ca82d40b12aaf06263808 100644
--- a/include/asterisk/channel.h
+++ b/include/asterisk/channel.h
@@ -125,11 +125,7 @@ References:
 
 #include "asterisk/abstract_jb.h"
 
-#ifdef HAVE_SYS_POLL_H
-#include <sys/poll.h>
-#else
 #include "asterisk/poll-compat.h"
-#endif
 
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
diff --git a/include/asterisk/io.h b/include/asterisk/io.h
index ee22994a42914dbb11b3a4a521a23725fb6ba9d7..2bddd3780b22d1876ac771789dc153fd9a2373a7 100644
--- a/include/asterisk/io.h
+++ b/include/asterisk/io.h
@@ -23,11 +23,7 @@
 #ifndef _ASTERISK_IO_H
 #define _ASTERISK_IO_H
 
-#ifdef HAVE_SYS_POLL_H
-#include <sys/poll.h>		/* For POLL* constants */
-#else
 #include "asterisk/poll-compat.h"
-#endif
 
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
diff --git a/include/asterisk/poll-compat.h b/include/asterisk/poll-compat.h
index 5f795a894131d6967ab102dbf4aa4a47764f4e29..1156e694bdcbb5a74e4cb94d41bc2ebc9c8c57cc 100644
--- a/include/asterisk/poll-compat.h
+++ b/include/asterisk/poll-compat.h
@@ -76,8 +76,16 @@
 	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
@@ -86,26 +94,24 @@
 #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 */
diff --git a/main/Makefile b/main/Makefile
index eee481c145475c7b9730afc15c791d6ec8339083..3e6179229c2cbf154a920edd28330d2b010202b5 100644
--- a/main/Makefile
+++ b/main/Makefile
@@ -29,7 +29,7 @@ OBJS= tcptls.o io.o sched.o logger.o frame.o loader.o config.o channel.o \
 	strcompat.o threadstorage.o dial.o event.o adsistub.o audiohook.o \
 	astobj2.o hashtab.o global_datastores.o version.o \
 	features.o taskprocessor.o timing.o datastore.o xml.o xmldoc.o \
-	strings.o bridging.o
+	strings.o bridging.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
@@ -44,14 +44,6 @@ AST_LIBS += $(OPENSSL_LIB)
 AST_LIBS += $(BKTR_LIB)
 AST_LIBS += $(LIBXML2_LIB) 
 
-ifeq ($(POLL_AVAILABLE),)
-  OBJS+=poll.o
-else
-  ifneq ($(findstring darwin,$(OSARCH)),)
-    OBJS+=poll.o
-  endif
-endif
-
 ifneq ($(findstring $(OSARCH), linux-gnu uclinux linux-uclibc linux-gnueabi ),)
   ifneq ($(findstring LOADABLE_MODULES,$(MENUSELECT_CFLAGS)),)
   AST_LIBS+=-ldl
diff --git a/main/asterisk.c b/main/asterisk.c
index 8850ae0184db11a5b5886ae4d818a2094c8aeec7..08c7f055cce0ac73b7b2ba69436c001370c11957 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -137,6 +137,7 @@ int daemon(int, int);  /* defined in libresolv of all places */
 #include "asterisk/dsp.h"
 #include "asterisk/buildinfo.h"
 #include "asterisk/xmldoc.h"
+#include "asterisk/poll-compat.h"
 
 #include "asterisk/doxyref.h"		/* Doxygen documentation */
 
@@ -1213,7 +1214,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));
@@ -1266,7 +1267,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)
@@ -2081,7 +2082,7 @@ static int ast_el_read_char(EditLine *editline, 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;
@@ -2649,7 +2650,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 buffer[512] = "", *curline = buffer, *nextline;
 			int not_written = 1;
 
@@ -3013,7 +3014,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);
diff --git a/main/channel.c b/main/channel.c
index 782629312a56c20dd4ca71ece637a5f21b074cfd..475e10ae8b570eabc9b5862e4902688f7945c792 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -2029,12 +2029,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);
diff --git a/main/io.c b/main/io.c
index 68b73d26cd16f463cee00496733165aeec1b9a58..8d51f4936fe4a4887c030409469ab22c371fc9b4 100644
--- a/main/io.c
+++ b/main/io.c
@@ -272,8 +272,9 @@ int ast_io_wait(struct io_context *ioc, int howlong)
 
 	DEBUG(ast_debug(1, "ast_io_wait()\n"));
 
-	if ((res = poll(ioc->fds, ioc->fdcnt, howlong)) <= 0)
+	if ((res = ast_poll(ioc->fds, ioc->fdcnt, howlong)) <= 0) {
 		return res;
+	}
 
 	/* At least one event tripped */
 	origcnt = ioc->fdcnt;
diff --git a/main/poll.c b/main/poll.c
index 823d0cbd43b78525fd21a30291457e5f677ab9f6..bb93125a6b03a23285860b10674564a312919138 100644
--- a/main/poll.c
+++ b/main/poll.c
@@ -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
 
-
 /*---------------------------------------------------------------------------*\
 			     Private Functions
 \*---------------------------------------------------------------------------*/
@@ -203,7 +206,7 @@ static struct timeval *map_timeout
 
 	return pResult;
 }
-
+
 static void map_select_results
 #if __STDC__ > 0
 			 (struct pollfd *pArray,
@@ -246,22 +249,12 @@ static void map_select_results
 
 	return;
 }
-
+
 /*---------------------------------------------------------------------------*\
 			     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 */
@@ -295,3 +288,5 @@ int poll
 
 	return ready_descriptors;
 }
+
+#endif /* AST_POLL_COMPAT */
diff --git a/main/utils.c b/main/utils.c
index 8ed4a968a90366b05c358c469121c5e9f6dc75b9..0e05c4d3c73ce197172fa01ac2fe056c3348831c 100644
--- a/main/utils.c
+++ b/main/utils.c
@@ -1054,7 +1054,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);
 }
 
 static int ast_wait_for_output(int fd, int timeoutms)
@@ -1068,7 +1068,7 @@ static int ast_wait_for_output(int fd, int timeoutms)
 	int elapsed = 0;
 
 	/* 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");
diff --git a/res/res_agi.c b/res/res_agi.c
index 34247a916fd4bb1394a597ab060bae9ae935cebd..8a128e2a298a90eb698296b47e25dc95153b4aaf 100644
--- a/res/res_agi.c
+++ b/res/res_agi.c
@@ -814,7 +814,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",