aboutsummaryrefslogtreecommitdiffstats
path: root/manager.c
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-04-24 23:02:21 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-04-24 23:02:21 +0000
commita7e3af17b17a18577bffea614df5851653933ab1 (patch)
treedf9f085479e929f714f7a841124286aaf935ce41 /manager.c
parent59969dc2e014eaf4ac5a3650cc99aa631a4cd606 (diff)
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
Diffstat (limited to 'manager.c')
-rwxr-xr-xmanager.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/manager.c b/manager.c
index b46685e3c..abef7a523 100755
--- a/manager.c
+++ b/manager.c
@@ -25,6 +25,7 @@
#include <signal.h>
#include <errno.h>
#include <unistd.h>
+#include <sys/poll.h>
#include <asterisk/channel.h>
#include <asterisk/file.h>
#include <asterisk/manager.h>
@@ -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;x<s->inlen;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) {