aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2009-03-18 14:32:47 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2009-03-18 14:32:47 +0000
commitd47911e89926ae860452f14159306f636677dd32 (patch)
tree0429fde883aee5da81cec0280b5c58a330b71e71 /include
parent1f818fd0f248e3b0c477efecc870f4b1fb1af3f5 (diff)
Merged revisions 182847 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ................ r182847 | russell | 2009-03-17 21:28:55 -0500 (Tue, 17 Mar 2009) | 52 lines Merged revisions 182810 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r182810 | russell | 2009-03-17 21:09:13 -0500 (Tue, 17 Mar 2009) | 44 lines Fix cases where the internal poll() was not being used when it needed to be. 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: http://svn.digium.com/svn/asterisk/branches/1.6.1@182946 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'include')
-rw-r--r--include/asterisk/autoconfig.h.in3
-rw-r--r--include/asterisk/channel.h4
-rw-r--r--include/asterisk/io.h4
-rw-r--r--include/asterisk/poll-compat.h30
4 files changed, 21 insertions, 20 deletions
diff --git a/include/asterisk/autoconfig.h.in b/include/asterisk/autoconfig.h.in
index e567f45ca..ef089e805 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 08c923df2..b7bc66fa7 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 ee22994a4..2bddd3780 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 5f795a894..1156e694b 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 */