[asterisk-commits] tilghman: branch tilghman/ast_select r282533 - in /team/tilghman/ast_select: ...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Aug 16 18:34:06 CDT 2010
Author: tilghman
Date: Mon Aug 16 18:34:03 2010
New Revision: 282533
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=282533
Log:
Changes for Mac OS X
Modified:
team/tilghman/ast_select/include/asterisk/select.h
team/tilghman/ast_select/main/poll.c
team/tilghman/ast_select/tests/test_poll.c
Modified: team/tilghman/ast_select/include/asterisk/select.h
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/ast_select/include/asterisk/select.h?view=diff&rev=282533&r1=282532&r2=282533
==============================================================================
--- team/tilghman/ast_select/include/asterisk/select.h (original)
+++ team/tilghman/ast_select/include/asterisk/select.h Mon Aug 16 18:34:03 2010
@@ -24,6 +24,7 @@
#define __AST_SELECT_H
#include <sys/select.h>
+#include <errno.h>
#include "asterisk/utils.h"
#ifdef __cplusplus
@@ -72,17 +73,21 @@
*/
static inline int ast_select(int nfds, ast_fdset *rfds, ast_fdset *wfds, ast_fdset *efds, struct timeval *tvp)
{
+#ifdef __linux__
ast_assert((unsigned int) nfds <= ast_FD_SETSIZE);
-#ifdef __linux__
return select(nfds, (fd_set *) rfds, (fd_set *) wfds, (fd_set *) efds, tvp);
#else
+ int save_errno = 0;
+
+ ast_assert((unsigned int) nfds <= ast_FD_SETSIZE);
if (tvp) {
struct timeval tv, tvstart, tvend, tvlen;
int res;
tv = *tvp;
gettimeofday(&tvstart, NULL);
- res = select(nfds, rfds, wfds, efds, tvp);
+ res = select(nfds, (fd_set *) rfds, (fd_set *) wfds, (fd_set *) efds, tvp);
+ save_errno = errno;
gettimeofday(&tvend, NULL);
timersub(&tvend, &tvstart, &tvlen);
timersub(&tv, &tvlen, tvp);
@@ -90,10 +95,11 @@
tvp->tv_sec = 0;
tvp->tv_usec = 0;
}
+ errno = save_errno;
return res;
}
else
- return select(nfds, rfds, wfds, efds, NULL);
+ return select(nfds, (fd_set *) rfds, (fd_set *) wfds, (fd_set *) efds, NULL);
#endif
}
Modified: team/tilghman/ast_select/main/poll.c
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/ast_select/main/poll.c?view=diff&rev=282533&r1=282532&r2=282533
==============================================================================
--- team/tilghman/ast_select/main/poll.c (original)
+++ team/tilghman/ast_select/main/poll.c Mon Aug 16 18:34:03 2010
@@ -78,6 +78,7 @@
#include <sys/time.h> /* time definitions */
#include <assert.h> /* assertion macros */
#include <string.h> /* string functions */
+#include <errno.h>
#include "asterisk/poll-compat.h" /* this package */
@@ -204,13 +205,13 @@
/* Exception events take priority over input events. */
pCur->revents = 0;
- if (FD_ISSET(pCur->fd, pExceptSet)) {
+ if (FD_ISSET(pCur->fd, (fd_set *) pExceptSet)) {
pCur->revents |= POLLPRI;
- } else if (FD_ISSET(pCur->fd, pReadSet)) {
+ } else if (FD_ISSET(pCur->fd, (fd_set *) pReadSet)) {
pCur->revents |= POLLIN;
}
- if (FD_ISSET(pCur->fd, pWriteSet)) {
+ if (FD_ISSET(pCur->fd, (fd_set *) pWriteSet)) {
pCur->revents |= POLLOUT;
}
}
@@ -232,6 +233,7 @@
int ready_descriptors; /* function result */
int max_fd = 0; /* maximum fd value */
struct timeval *pTimeout; /* actually passed */
+ int save_errno;
FD_ZERO(&read_descs);
FD_ZERO(&write_descs);
@@ -252,12 +254,14 @@
ready_descriptors = ast_select(max_fd + 1, &read_descs, &write_descs,
&except_descs, pTimeout);
+ save_errno = errno;
if (ready_descriptors >= 0) {
map_select_results (pArray, n_fds,
&read_descs, &write_descs, &except_descs);
}
+ errno = save_errno;
return ready_descriptors;
}
#endif /* AST_POLL_COMPAT */
Modified: team/tilghman/ast_select/tests/test_poll.c
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/ast_select/tests/test_poll.c?view=diff&rev=282533&r1=282532&r2=282533
==============================================================================
--- team/tilghman/ast_select/tests/test_poll.c (original)
+++ team/tilghman/ast_select/tests/test_poll.c Mon Aug 16 18:34:03 2010
@@ -47,7 +47,7 @@
static void *failsafe_cancel(void *vparent)
{
- pthread_t parent = (long) vparent;
+ pthread_t parent = (pthread_t) (long) vparent;
sleep(1);
pthread_testcancel();
@@ -182,13 +182,13 @@
RESET;
if ((res2 = ast_poll(pfd, FDNO, -1)) != 2) {
- ast_test_status_update(test, "ast_poll does not return that only two handles are available (inf timeout): %d\n", res2);
+ ast_test_status_update(test, "ast_poll does not return that only two handles are available (inf timeout): %d, %s\n", res2, res2 == -1 ? strerror(errno) : "");
res = AST_TEST_FAIL;
}
RESET;
if ((res2 = ast_poll2(pfd, FDNO, NULL)) != 2) {
- ast_test_status_update(test, "ast_poll2 does not return that only two handles are available (inf timeout): %d\n", res2);
+ ast_test_status_update(test, "ast_poll2 does not return that only two handles are available (inf timeout): %d %s\n", res2, res2 == -1 ? strerror(errno) : "");
res = AST_TEST_FAIL;
}
@@ -199,25 +199,25 @@
RESET;
if (ast_poll(pfd, FDNO, 0) != 2) {
- ast_test_status_update(test, "ast_poll does not return that only two handles are available (0 timeout)\n");
+ ast_test_status_update(test, "ast_poll does not return that only two handles are available (0 timeout): %d, %s\n", res2, res2 == -1 ? strerror(errno) : "");
res = AST_TEST_FAIL;
}
RESET;
if (ast_poll2(pfd, FDNO, &tv) != 2) {
- ast_test_status_update(test, "ast_poll2 does not return that only two handles are available (0 timeout)\n");
+ ast_test_status_update(test, "ast_poll2 does not return that only two handles are available (0 timeout): %d, %s\n", res2, res2 == -1 ? strerror(errno) : "");
res = AST_TEST_FAIL;
}
RESET;
if (ast_poll(pfd, FDNO, 1) != 2) {
- ast_test_status_update(test, "ast_poll does not return that only two handles are available (1ms timeout)\n");
+ ast_test_status_update(test, "ast_poll does not return that only two handles are available (1ms timeout): %d, %s\n", res2, res2 == -1 ? strerror(errno) : "");
res = AST_TEST_FAIL;
}
tv.tv_usec = 1000;
if (ast_poll2(pfd, FDNO, &tv) != 2) {
- ast_test_status_update(test, "ast_poll2 does not return that only two handles are available (1ms timeout)\n");
+ ast_test_status_update(test, "ast_poll2 does not return that only two handles are available (1ms timeout): %d, %s\n", res2, res2 == -1 ? strerror(errno) : "");
res = AST_TEST_FAIL;
}
More information about the asterisk-commits
mailing list