diff --git a/src/posix/platform/radio_spinel.cpp b/src/posix/platform/radio_spinel.cpp index 4cc048e92..cd67543cb 100644 --- a/src/posix/platform/radio_spinel.cpp +++ b/src/posix/platform/radio_spinel.cpp @@ -51,6 +51,7 @@ #include #include #include +#include #include #include #include @@ -308,6 +309,8 @@ exit: void RadioSpinel::Deinit(void) { mHdlcInterface.Deinit(); + // This allows implementing pseudo reset. + new (this) RadioSpinel(); } void RadioSpinel::HandleSpinelFrame(HdlcInterface::RxFrameBuffer &aFrameBuffer) diff --git a/src/posix/platform/uart.c b/src/posix/platform/uart.c index 4534ceee0..b8ffa9a2e 100644 --- a/src/posix/platform/uart.c +++ b/src/posix/platform/uart.c @@ -67,6 +67,9 @@ otError otPlatUartEnable(void) struct sockaddr_un sockname; int ret; + // This allows implementing pseudo reset. + otEXPECT(sUartSocket == -1); + sUartSocket = SocketWithCloseExec(AF_UNIX, SOCK_STREAM, 0); if (sUartSocket == -1) @@ -109,6 +112,8 @@ otError otPlatUartEnable(void) { DieNowWithMessage("listen", OT_EXIT_ERROR_ERRNO); } + +exit: #endif // OPENTHREAD_ENABLE_POSIX_APP_DAEMON sEnabled = true; @@ -135,6 +140,7 @@ otError otPlatUartDisable(void) if (sUartLock != -1) { + (void)flock(sUartLock, LOCK_UN); close(sUartLock); sUartLock = -1; }