[posix] wait for writable before next try (#5143)

This commit waits fd to be writable before try writing next time.
This commit is contained in:
Yakun Xu
2020-06-30 11:00:11 -07:00
committed by GitHub
parent 284cd96886
commit eaaaa59071
+7 -5
View File
@@ -235,16 +235,18 @@ otError HdlcInterface::Write(const uint8_t *aFrame, uint16_t aLength)
{
ssize_t rval = write(mSockFd, aFrame, aLength);
if (rval > 0)
if (rval == aLength)
{
break;
}
else if (rval > 0)
{
aLength -= static_cast<uint16_t>(rval);
aFrame += static_cast<uint16_t>(rval);
continue;
}
if ((rval < 0) && (errno != EAGAIN) && (errno != EWOULDBLOCK) && (errno != EINTR))
else if (rval < 0)
{
DieNow(OT_EXIT_ERROR_ERRNO);
VerifyOrDie((errno == EAGAIN) || (errno == EWOULDBLOCK) || (errno == EINTR), OT_EXIT_ERROR_ERRNO);
}
SuccessOrExit(error = WaitForWritable());