mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-18 18:58:22 +00:00
Fix manager EINTR issue (bug #5247)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6644 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
27
manager.c
27
manager.c
@@ -1311,17 +1311,22 @@ static int get_input(struct mansession *s, char *output)
|
|||||||
}
|
}
|
||||||
fds[0].fd = s->fd;
|
fds[0].fd = s->fd;
|
||||||
fds[0].events = POLLIN;
|
fds[0].events = POLLIN;
|
||||||
res = poll(fds, 1, -1);
|
do {
|
||||||
if (res < 0) {
|
res = poll(fds, 1, -1);
|
||||||
ast_log(LOG_WARNING, "Select returned error: %s\n", strerror(errno));
|
if (res < 0) {
|
||||||
return -1;
|
if (errno == EINTR)
|
||||||
} else if (res > 0) {
|
continue;
|
||||||
ast_mutex_lock(&s->lock);
|
ast_log(LOG_WARNING, "Select returned error: %s\n", strerror(errno));
|
||||||
res = read(s->fd, s->inbuf + s->inlen, sizeof(s->inbuf) - 1 - s->inlen);
|
return -1;
|
||||||
ast_mutex_unlock(&s->lock);
|
} else if (res > 0) {
|
||||||
if (res < 1)
|
ast_mutex_lock(&s->lock);
|
||||||
return -1;
|
res = read(s->fd, s->inbuf + s->inlen, sizeof(s->inbuf) - 1 - s->inlen);
|
||||||
}
|
ast_mutex_unlock(&s->lock);
|
||||||
|
if (res < 1)
|
||||||
|
return -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} while(1);
|
||||||
s->inlen += res;
|
s->inlen += res;
|
||||||
s->inbuf[s->inlen] = '\0';
|
s->inbuf[s->inlen] = '\0';
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user