From: Mark Spencer Date: Fri, 14 Oct 2005 20:37:40 +0000 (+0000) Subject: Fix carefulwrite and its usage within manager (bug #5355, maybe) X-Git-Tag: 1.2.0-beta2~129 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0aec4ef713376d2cbc8ea05ecc9ef641b958642e;p=thirdparty%2Fasterisk.git 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 --- diff --git a/manager.c b/manager.c index 55120e9661..bd99025a2e 100755 --- a/manager.c +++ b/manager.c @@ -118,12 +118,15 @@ int ast_carefulwrite(int fd, char *s, int len, int timeoutms) if (res < 0) res = 0; len -= res; s += res; - fds[0].fd = fd; - fds[0].events = POLLOUT; - /* Wait until writable again */ - res = poll(fds, 1, timeoutms); - if (res < 1) - return -1; + res = 0; + if (len) { + fds[0].fd = fd; + fds[0].events = POLLOUT; + /* Wait until writable again */ + res = poll(fds, 1, timeoutms); + if (res < 1) + return -1; + } } return res; } @@ -1292,7 +1295,7 @@ static int process_message(struct mansession *s, struct message *m) ast_mutex_lock(&s->__lock); s->busy = 0; 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; break; }