diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-03-18 02:09:13 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-03-18 02:09:13 +0000 |
commit | 91586477bbe6336c9debddf804edb8d02db71ab6 (patch) | |
tree | 1a985d7fb6aab02b48d7176a698f2268f15f44a4 /main/poll.c | |
parent | ab574c1a269daa27014b5f5eb315ec1332d9a13c (diff) |
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.4@182810 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/poll.c')
-rw-r--r-- | main/poll.c | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/main/poll.c b/main/poll.c index c053ba015..aba6e593e 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 \*---------------------------------------------------------------------------*/ @@ -209,7 +212,7 @@ static struct timeval *map_timeout return pResult; } - + static void map_select_results #if __STDC__ > 0 (struct pollfd *pArray, @@ -251,22 +254,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 */ @@ -304,3 +297,5 @@ int poll return ready_descriptors; } + +#endif /* AST_POLL_COMPAT */ |