diff --git a/nest/cli.c b/nest/cli.c index 6e7e9ecc..5debc7cc 100644 --- a/nest/cli.c +++ b/nest/cli.c @@ -64,7 +64,7 @@ * and its outpos field is the position of the read head. */ -#define LOCAL_DEBUG 1 +#undef LOCAL_DEBUG #include "nest/bird.h" #include "nest/cli.h" @@ -243,6 +243,7 @@ cli_free_out(cli *c) static void cli_write(cli *c) { + DBG("CLI write begin\n"); sock *s = c->socket; while (c->tx_pos) @@ -261,7 +262,7 @@ cli_write(cli *c) /* Everything is written */ s->tbuf = NULL; cli_free_out(c); - ev_schedule(c->event); + DBG("CLI write done\n"); } void @@ -484,6 +485,24 @@ cli_yield(cli *c) DBG("CLI: Yield resumed\n"); } +void +cli_sleep(cli *c) +{ + c->state = CLI_STATE_SLEEP; + DBG("CLI: Sleeping\n"); + coro_suspend(); + c->state = CLI_STATE_RUN; + DBG("CLI: Woken up\n"); +} + +void +cli_wakeup(cli *c) +{ + ASSERT(c->state == CLI_STATE_SLEEP); + c->state = CLI_STATE_YIELD; + ev_schedule(c->event); +} + static void cli_coroutine(void *_c) { diff --git a/nest/cli.h b/nest/cli.h index 18e680e2..80aea375 100644 --- a/nest/cli.h +++ b/nest/cli.h @@ -33,6 +33,7 @@ enum cli_state { CLI_STATE_WAIT_RX, CLI_STATE_WAIT_TX, CLI_STATE_YIELD, + CLI_STATE_SLEEP, }; typedef struct cli { @@ -79,6 +80,8 @@ void cli_printf(cli *, int, char *, ...); void cli_write_trigger(cli *c); void cli_set_log_echo(cli *, uint mask, uint size); void cli_yield(cli *c); +void cli_sleep(cli *c); +void cli_wakeup(cli *c); /* Functions provided to sysdep layer */