[posix] fix udp close (#5690)

This commit is contained in:
Rongli Sun
2020-10-25 21:05:59 -07:00
committed by GitHub
parent fbcc9a662b
commit 7a24666bf4
+4 -1
View File
@@ -240,7 +240,10 @@ otError otPlatUdpClose(otUdpSocket *aUdpSocket)
otError error = OT_ERROR_NONE;
int fd;
VerifyOrExit(aUdpSocket->mHandle != nullptr, error = OT_ERROR_INVALID_ARGS);
// Only call `close()` on platform UDP sockets.
// Platform UDP sockets always have valid `mHandle` upon creation.
VerifyOrExit(aUdpSocket->mHandle != nullptr);
fd = FdFromHandle(aUdpSocket->mHandle);
VerifyOrExit(0 == close(fd), error = OT_ERROR_FAILED);