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:
parent
ae6ed44883
commit
2445ba7a26
2 changed files with 4 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue