Fix carefulwrite and its usage within manager (bug #5355, maybe)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6792 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Mark Spencer
2005-10-14 20:37:40 +00:00
parent 141d9f7156
commit 0aec4ef713

View File

@@ -118,12 +118,15 @@ int ast_carefulwrite(int fd, char *s, int len, int timeoutms)
if (res < 0) res = 0; if (res < 0) res = 0;
len -= res; len -= res;
s += res; s += res;
fds[0].fd = fd; res = 0;
fds[0].events = POLLOUT; if (len) {
/* Wait until writable again */ fds[0].fd = fd;
res = poll(fds, 1, timeoutms); fds[0].events = POLLOUT;
if (res < 1) /* Wait until writable again */
return -1; res = poll(fds, 1, timeoutms);
if (res < 1)
return -1;
}
} }
return res; return res;
} }
@@ -1292,7 +1295,7 @@ static int process_message(struct mansession *s, struct message *m)
ast_mutex_lock(&s->__lock); ast_mutex_lock(&s->__lock);
s->busy = 0; s->busy = 0;
while(s->eventq) { while(s->eventq) {
if (ast_carefulwrite(s->fd, s->eventq->eventdata, strlen(s->eventq->eventdata), s->writetimeout)) { if (ast_carefulwrite(s->fd, s->eventq->eventdata, strlen(s->eventq->eventdata), s->writetimeout) < 0) {
ret = -1; ret = -1;
break; break;
} }