shell: fix possible hanging reason when history feature is used

Fixed possible race condition.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
This commit is contained in:
Jakub Rzeszutko 2018-10-11 14:51:13 +02:00 committed by Carles Cufí
commit 2445ba7a26
2 changed files with 4 additions and 2 deletions

View file

@ -73,7 +73,9 @@ static int read(const struct shell_transport *transport,
void *data, size_t length, size_t *cnt)
{
struct shell_uart *sh_uart = (struct shell_uart *)transport->ctx;
u32_t key;
key = irq_lock();
if (sh_uart->rx_cnt) {
memcpy(data, sh_uart->rx, 1);
sh_uart->rx_cnt = 0;
@ -81,6 +83,7 @@ static int read(const struct shell_transport *transport,
} else {
*cnt = 0;
}
irq_unlock(key);
return 0;
}