From a7e3af17b17a18577bffea614df5851653933ab1 Mon Sep 17 00:00:00 2001 From: markster Date: Sat, 24 Apr 2004 23:02:21 +0000 Subject: Change select references to poll in core asterisk functions (hope this works) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@2756 f38db490-d61c-443f-a65b-d21fe96a405b --- manager.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'manager.c') diff --git a/manager.c b/manager.c index b46685e3c..abef7a523 100755 --- a/manager.c +++ b/manager.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -68,8 +69,7 @@ int ast_carefulwrite(int fd, char *s, int len, int timeoutms) /* Try to write string, but wait no more than ms milliseconds before timing out */ int res=0; - struct timeval tv; - fd_set fds; + struct pollfd fds[1]; while(len) { res = write(fd, s, len); if ((res < 0) && (errno != EAGAIN)) { @@ -78,12 +78,10 @@ int ast_carefulwrite(int fd, char *s, int len, int timeoutms) if (res < 0) res = 0; len -= res; s += res; - tv.tv_sec = timeoutms / 1000; - tv.tv_usec = timeoutms % 1000; - FD_ZERO(&fds); - FD_SET(fd, &fds); + fds[0].fd = fd; + fds[0].events = POLLOUT; /* Wait until writable again */ - res = select(fd + 1, NULL, &fds, NULL, &tv); + res = poll(fds, 1, timeoutms); if (res < 1) return -1; } @@ -715,7 +713,7 @@ static int get_input(struct mansession *s, char *output) /* output must have at least sizeof(s->inbuf) space */ int res; int x; - fd_set fds; + struct pollfd fds[1]; for (x=1;xinlen;x++) { if ((s->inbuf[x] == '\n') && (s->inbuf[x-1] == '\r')) { /* Copy output data up to and including \r\n */ @@ -732,9 +730,9 @@ static int get_input(struct mansession *s, char *output) ast_log(LOG_WARNING, "Dumping long line with no return from %s: %s\n", inet_ntoa(s->sin.sin_addr), s->inbuf); s->inlen = 0; } - FD_ZERO(&fds); - FD_SET(s->fd, &fds); - res = ast_select(s->fd + 1, &fds, NULL, NULL, NULL); + fds[0].fd = s->fd; + fds[0].events = POLLIN; + res = poll(fds, 1, -1); if (res < 0) { ast_log(LOG_WARNING, "Select returned error: %s\n", strerror(errno)); } else if (res > 0) { -- cgit v1.2.3