diff options
author | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-10-14 20:37:40 +0000 |
---|---|---|
committer | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-10-14 20:37:40 +0000 |
commit | 3a74931cd7728c70ab2fe574334900d2e07dd802 (patch) | |
tree | 575ad4dd3e4c239517c277db18a1aaf30ba8ebf6 /manager.c | |
parent | 8dd051949d230cb322c858ec5f841e02c0ef5355 (diff) |
Fix carefulwrite and its usage within manager (bug #5355, maybe)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6792 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'manager.c')
-rwxr-xr-x | manager.c | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -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; } |