assert(eb != NULL);
CVCL_Load(heritage.vcl_file, "boot");
- cli = cli_setup(heritage.fds[2], heritage.fds[1], 0, cli_proto);
+ cli = cli_setup(eb, heritage.fds[2], heritage.fds[1], 0, cli_proto);
evtimer_set(&ev_keepalive, timer_keepalive, NULL);
event_base_set(eb, &ev_keepalive);
printf("%s(%p, %d, %p)\n", __func__, (void*)bev, what, arg);
}
+/*
+ * XXX: included in libevent in CVS
+ */
+
+static int
+bufferevent_base_set(struct event_base *base, struct bufferevent *bufev)
+{
+ int res;
+
+ res = event_base_set(base, &bufev->ev_read);
+ if (res == -1)
+ return (res);
+
+ res = event_base_set(base, &bufev->ev_write);
+ return (res);
+}
+
struct cli *
-cli_setup(int fdr, int fdw, int ver, struct cli_proto *cli_proto)
+cli_setup(struct event_base *eb, int fdr, int fdw, int ver, struct cli_proto *cli_proto)
{
struct cli *cli;
cli->bev0 = bufferevent_new(fdr, rdcb, wrcb, excb, cli);
assert(cli->bev0 != NULL);
+ bufferevent_base_set(eb, cli->bev0);
if (fdr == fdw)
cli->bev1 = cli->bev0;
else
cli->bev1 = bufferevent_new(fdw, rdcb, wrcb, excb, cli);
assert(cli->bev1 != NULL);
+ bufferevent_base_set(eb, cli->bev1);
cli->sb = sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND);
assert(cli->sb != NULL);
struct cli_proto *cli_proto;
};
-struct cli *cli_setup(int fdr, int fdw, int ver, struct cli_proto *cli_proto);
+struct cli *cli_setup(struct event_base *eb, int fdr, int fdw, int ver, struct cli_proto *cli_proto);
void cli_suspend(struct cli *cli);
void cli_resume(struct cli *cli);
void cli_encode_string(struct evbuffer *buf, char *b);
* $Id$
*/
-extern struct event_base *eb;
+extern struct event_base *mgt_eb;
void mgt_child_start(void);
void mgt_child_stop(void);
assert(child_cli1 != NULL);
evtimer_set(&ev_child_pingpong, child_pingpong, NULL);
+ event_base_set(mgt_eb, &ev_child_pingpong);
child_pingpong(0, 0, NULL);
}
/*--------------------------------------------------------------------*/
struct heritage heritage;
-struct event_base *eb;
+struct event_base *mgt_eb;
/*--------------------------------------------------------------------
* Generic passthrough for CLI functions
struct cli *cli;
int i;
- eb = event_init();
- assert(eb != NULL);
+ mgt_eb = event_init();
+ assert(mgt_eb != NULL);
- cli = cli_setup(0, 1, 1, cli_proto);
+ cli = cli_setup(mgt_eb, 0, 1, 1, cli_proto);
signal_set(&e_sigchld, SIGCHLD, mgt_sigchld, NULL);
signal_add(&e_sigchld, NULL);
- i = event_dispatch();
+ i = event_base_loop(mgt_eb, 0);
if (i != 0)
printf("event_dispatch() = %d\n", i);