[posix] do not exit upon recv getting EINTR (#4126)

This commit is contained in:
Jiacheng Guo
2019-08-27 08:39:29 -07:00
committed by Jonathan Hui
parent 711c03aa1e
commit 3198a3be69
+14 -5
View File
@@ -28,6 +28,8 @@
#include "platform-posix.h"
#include <errno.h>
#include <openthread/dataset.h>
#include <openthread/random_noncrypto.h>
#include <openthread/platform/alarm-micro.h>
@@ -815,15 +817,22 @@ void platformRadioProcess(otInstance *aInstance, const fd_set *aReadFdSet, const
{
ssize_t rval = recvfrom(sRxFd, (char *)&sReceiveMessage, sizeof(sReceiveMessage), 0, NULL, NULL);
if (rval < 0)
if (rval > 0)
{
sReceiveFrame.mLength = (uint8_t)(rval - 1);
radioReceive(aInstance);
}
else if (rval == 0)
{
// socket is closed, which should not happen
assert(false);
}
else if (errno != EINTR && errno != EAGAIN)
{
perror("recvfrom(sRxFd)");
exit(EXIT_FAILURE);
}
sReceiveFrame.mLength = (uint8_t)(rval - 1);
radioReceive(aInstance);
}
#endif