aboutsummaryrefslogtreecommitdiffstats
path: root/glougloud/external
diff options
context:
space:
mode:
authorLaurent Ghigonis <laurent@p1sec.com>2012-07-22 01:07:01 +0200
committerLaurent Ghigonis <laurent@p1sec.com>2012-07-22 01:07:01 +0200
commit547ccfb9f53485f8b56473f14cbde10cfcbeed07 (patch)
treece5374560fcddd9645a49d321dc5cc5d9abcc9bd /glougloud/external
parentmake it at least compile on linux. (diff)
downloadglouglou-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')
-rw-r--r--glougloud/external/imsgev.c20
-rw-r--r--glougloud/external/imsgev.h3
2 files changed, 17 insertions, 6 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;
}
diff --git a/glougloud/external/imsgev.h b/glougloud/external/imsgev.h
index 71163fb..a0d0947 100644
--- a/glougloud/external/imsgev.h
+++ b/glougloud/external/imsgev.h
@@ -30,6 +30,7 @@ struct imsgev {
short events;
int terminate;
void (*callback)(struct imsgev *, int, struct imsg *);
+ void (*needfd)(struct imsgev *);
};
#define IMSGEV_IMSG 0
@@ -39,7 +40,7 @@ struct imsgev {
#define IMSGEV_EIMSG 4
void imsgev_init(struct imsgev *, int, void *, void (*)(struct imsgev *,
- int, struct imsg *));
+ int, struct imsg *), void (*)(struct imsgev *));
int imsgev_compose(struct imsgev *, u_int16_t, u_int32_t, u_int32_t, int,
void *, u_int16_t);
void imsgev_close(struct imsgev *);