diff options
author | Laurent Ghigonis <laurent@p1sec.com> | 2012-07-22 01:07:01 +0200 |
---|---|---|
committer | Laurent Ghigonis <laurent@p1sec.com> | 2012-07-22 01:07:01 +0200 |
commit | 547ccfb9f53485f8b56473f14cbde10cfcbeed07 (patch) | |
tree | ce5374560fcddd9645a49d321dc5cc5d9abcc9bd /glougloud/external/imsgev.c | |
parent | make it at least compile on linux. (diff) | |
download | glouglou-547ccfb9f53485f8b56473f14cbde10cfcbeed07.tar.xz glouglou-547ccfb9f53485f8b56473f14cbde10cfcbeed07.zip |
fix imcompatibility between imsg and imsgev !
during last commit, imsg was involontarily updated, and imsgev became
incompatible with it. so update imsgev to lastest version.
Diffstat (limited to 'glougloud/external/imsgev.c')
-rw-r--r-- | glougloud/external/imsgev.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/glougloud/external/imsgev.c b/glougloud/external/imsgev.c index 6a5052d..6b92d79 100644 --- a/glougloud/external/imsgev.c +++ b/glougloud/external/imsgev.c @@ -15,6 +15,7 @@ */ #include <sys/param.h> +#include <sys/queue.h> #include <sys/socket.h> #include <sys/uio.h> @@ -24,7 +25,6 @@ #include <string.h> #include <unistd.h> -#include "queue.h" #include "imsgev.h" void imsgev_add(struct imsgev *); @@ -33,7 +33,8 @@ void imsgev_disconnect(struct imsgev *, int); void imsgev_init(struct imsgev *iev, int fd, void *data, - void (*callback)(struct imsgev *, int, struct imsg *)) + void (*callback)(struct imsgev *, int, struct imsg *), + void (*needfd)(struct imsgev *)) { imsg_init(&iev->ibuf, fd); iev->terminate = 0; @@ -41,6 +42,7 @@ imsgev_init(struct imsgev *iev, int fd, void *data, iev->data = data; iev->handler = imsgev_dispatch; iev->callback = callback; + iev->needfd = needfd; iev->events = EV_READ; event_set(&iev->ev, iev->ibuf.fd, iev->events, iev->handler, iev); @@ -107,8 +109,16 @@ imsgev_dispatch(int fd, short ev, void *humppa) if (ev & EV_READ) { if ((n = imsg_read(ibuf)) == -1) { - imsgev_disconnect(iev, IMSGEV_EREAD); - return; + /* if we don't have enough fds, free one up and retry */ + if (errno == EAGAIN) { + iev->needfd(iev); + n = imsg_read(ibuf); + } + + if (n == -1) { + imsgev_disconnect(iev, IMSGEV_EREAD); + return; + } } if (n == 0) { /* @@ -128,7 +138,7 @@ imsgev_dispatch(int fd, short ev, void *humppa) * closed, or some error occured. Both case are not recoverable * from the imsg perspective, so we treat it as a WRITE error. */ - if ((n = msgbuf_write(&ibuf->w)) != 0) { + if ((n = msgbuf_write(&ibuf->w)) != 1) { imsgev_disconnect(iev, IMSGEV_EWRITE); return; } |