mirror of
https://github.com/espressif/openthread.git
synced 2026-08-11 13:17:48 +00:00
[posix] return INVALID_STATE on EINVAL (#4959)
After adding and removing addresses, sendmsg call will return EINVAL for a short period of time. Return INVALID_STATE to inform callers to try again later.
This commit is contained in:
@@ -89,6 +89,7 @@ static otError transmitPacket(int aFd, uint8_t *aPayload, uint16_t aLength, cons
|
||||
struct msghdr msg;
|
||||
struct cmsghdr *cmsg;
|
||||
ssize_t rval;
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
memset(&peerAddr, 0, sizeof(peerAddr));
|
||||
peerAddr.sin6_port = htons(aMessageInfo.mPeerPort);
|
||||
@@ -157,7 +158,14 @@ static otError transmitPacket(int aFd, uint8_t *aPayload, uint16_t aLength, cons
|
||||
VerifyOrExit(rval > 0, perror("sendmsg"));
|
||||
|
||||
exit:
|
||||
return rval > 0 ? OT_ERROR_NONE : OT_ERROR_FAILED;
|
||||
// EINVAL happens when we shift from child to router and the
|
||||
// interface address changes. Ask callers to try again later.
|
||||
if (rval == -1)
|
||||
{
|
||||
error = (errno == EINVAL) ? OT_ERROR_INVALID_STATE : OT_ERROR_FAILED;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
static otError receivePacket(int aFd, uint8_t *aPayload, uint16_t &aLength, otMessageInfo &aMessageInfo)
|
||||
|
||||
Reference in New Issue
Block a user