[hdlc-interface] ignore errno EINTR in socket read (#3310)

This commit changes `HdlcInterface::Read()` method to ignore `errno`
`EINTR` (interrupt by a signal) during socket `read()`. It also
uses `exit()` on error.
This commit is contained in:
Abtin Keshavarzian
2018-11-19 09:47:08 -08:00
committed by Jonathan Hui
parent 3f3970ccaa
commit 3b158a61e9
+5 -10
View File
@@ -141,20 +141,15 @@ void HdlcInterface::Read(void)
rval = read(mSockFd, buffer, sizeof(buffer));
if (rval < 0)
{
perror("HdlcInterface::Read()");
if (errno != EAGAIN)
{
abort();
}
}
if (rval > 0)
{
Decode(buffer, static_cast<uint16_t>(rval));
}
else if ((rval < 0) && (errno != EAGAIN) && (errno != EINTR))
{
perror("HdlcInterface::Read()");
exit(OT_EXIT_FAILURE);
}
}
void HdlcInterface::Decode(const uint8_t *aBuffer, uint16_t aLength)