Skip to content

Commit 3399e06

Browse files
keviniornashif
authored andcommitted
shell: backend: telnet: Don't assert if connection closed
The code in shell_ops.c that calls telnet_write will assert if it returns non-zero. For a telnet shell it's normal that the network might disconnect unexepectedly, so that should not trigger an assert. Fixes #67637 Link: zephyrproject-rtos/zephyr#67637 Signed-off-by: Kevin ORourke <[email protected]>
1 parent 9a5cd08 commit 3399e06

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

subsys/shell/backends/shell_telnet.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,12 @@ static int telnet_write(const struct shell_transport *transport,
708708
err = telnet_send(true);
709709
if (err != 0) {
710710
*cnt = length;
711-
return err;
711+
if ((err == -ENOTCONN) || (err == -ENETDOWN)) {
712+
LOG_ERR("Network disconnected, shutting down");
713+
} else {
714+
LOG_ERR("Error %d, shutting down", err);
715+
}
716+
return 0; /* Return 0 to not trigger ASSERT in shell_ops.c */
712717
}
713718
}
714719

0 commit comments

Comments
 (0)