static void finish_ok(struct io_conn *conn, int *state) { ok1(*state == 1); ok1(io_conn_fd(conn) == expected_fd); (*state)++; io_break(state + 1); }
static struct io_plan *write_json(struct io_conn *conn, struct json_connection *jcon) { struct json_output *out; out = list_pop(&jcon->output, struct json_output, list); if (!out) { if (jcon->stop) { log_unusual(jcon->log, "JSON-RPC shutdown"); /* Return us to toplevel lightningd.c */ io_break(jcon->dstate); return io_close(conn); } /* Reader can go again now. */ io_wake(jcon); return io_out_wait(conn, jcon, write_json, jcon); } jcon->outbuf = tal_steal(jcon, out->json); tal_free(out); log_io(jcon->log, false, jcon->outbuf, strlen(jcon->outbuf)); return io_write(conn, jcon->outbuf, strlen(jcon->outbuf), write_json, jcon); }
static void finish_EBADF(struct io_conn *conn, int *state) { ok1(errno == EBADF); ok1(*state == 3); (*state)++; io_break(state + 1); }
static void init_conn(int fd, struct data *d) { ok1(d->state == 0); d->state++; io_set_finish(io_new_conn(fd, io_break(d, io_read(d->buf, sizeof(d->buf), read_done, d))), finish_ok, d); }
static void json_restart(struct command *cmd, const char *buffer, const jsmntok_t *params) { const jsmntok_t *p, *end; size_t n = 0; if (params->type != JSMN_ARRAY) { command_fail(cmd, "Need array to reexec"); return; } end = json_next(params); cmd->dstate->reexec = tal_arrz(cmd->dstate, char *, n+1); for (p = params + 1; p != end; p = json_next(p)) { tal_resizez(&cmd->dstate->reexec, n+2); cmd->dstate->reexec[n++] = tal_strndup(cmd->dstate->reexec, buffer + p->start, p->end - p->start); } debug_dump_peers(cmd->dstate); io_break(cmd->dstate); command_success(cmd, null_response(cmd)); }
static void finish_idle(struct io_conn *conn, struct data *d) { ok1(d->state == 3); d->state++; io_break(d); }
static void finish_ok(struct io_conn *conn, struct packet *pkt) { ok1(pkt->state == 3); pkt->state++; io_break(pkt, io_idle()); }
static void finish_ok(struct io_conn *conn, struct data *d) { ok1(d->state == 1); d->state++; io_break(d, io_idle()); }
static struct io_plan do_timeout(struct io_conn *conn, char *buf) { return io_break(buf, io_idle()); }
static void finish_ok(struct io_conn *conn, int *state) { ok1(*state == 1); (*state)++; io_break(state + 1, io_idle()); }