return plan;
}
+static struct io_plan io_never_called(struct io_conn *conn, void *arg)
+{
+ abort();
+}
+
+struct io_plan io_never(void)
+{
+ return io_always_(io_never_called, NULL);
+}
+
int io_conn_fd(const struct io_conn *conn)
{
return conn->fd.fd;
#define io_break(ret, plan) (io_plan_no_debug(), io_break_((ret), (plan)))
struct io_plan io_break_(void *ret, struct io_plan plan);
+/**
+ * io_never - assert if callback is called.
+ *
+ * Sometimes you want to make it clear that a callback should never happen
+ * (eg. for io_break). This will assert() if called.
+ *
+ * Example:
+ * static struct io_plan break_out(struct io_conn *conn, void *unused)
+ * {
+ * // We won't ever return from io_break
+ * return io_break(conn, io_never());
+ * }
+ */
+struct io_plan io_never(void);
+
/* FIXME: io_recvfrom/io_sendto */
/**
ok1(*state == 1);
ok1(io_conn_fd(conn) == expected_fd);
(*state)++;
- io_break(state + 1, io_idle());
+ io_break(state + 1, io_never());
}
static void init_conn(int fd, int *state)
{
ok1(d->state == 1);
d->state++;
- io_break(d, io_idle());
+ io_break(d, io_never());
}
static void init_conn(int fd, struct data *d)
{
ok1(d->state == 1);
d->state++;
- io_break(d, io_idle());
+ io_break(d, io_never());
}
static void init_conn(int fd, struct data *d)
{
ok1(d->state == 1);
d->state++;
- io_break(d, io_idle());
+ io_break(d, io_never());
}
static void init_conn(int fd, struct data *d)
{
ok1(d->state == 1);
d->state++;
- io_break(d, io_idle());
+ io_break(d, io_never());
}
static void init_conn(int fd, struct data *d)
{
ok1(d->state == 3);
d->state++;
- io_break(d, io_idle());
+ io_break(d, io_never());
}
static struct io_plan never(struct io_conn *conn, void *arg)
{
ok1(d->state == 2);
d->state++;
- io_break(d, io_idle());
+ io_break(d, io_never());
}
static void init_conn(int fd, struct data *d)
{
ok1(pkt->state == 3);
pkt->state++;
- io_break(pkt, io_idle());
+ io_break(pkt, io_never());
}
static int do_read_packet(int fd, struct io_plan *plan)
{
ok1(d->state == 1);
d->state++;
- io_break(d, io_idle());
+ io_break(d, io_never());
}
static struct io_plan write_buf(struct io_conn *conn, struct data *d)
{
ok1(d->state == 2);
d->state++;
- io_break(d, io_idle());
+ io_break(d, io_never());
}
static void init_conn(int fd, struct data *d)