mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 23:03:27 +08:00
ieee802154_req_data: Don't modify the IOB until we are certain that no EINTR errors will occur. Otherwise, the retry will fail
This commit is contained in:
@@ -82,12 +82,15 @@ int mac802154_req_data(MACHANDLE mac,
|
||||
uint8_t mhr_len = 3;
|
||||
int ret;
|
||||
|
||||
wlinfo("Received frame io_len=%u io_offset=%u\n",
|
||||
frame->io_offset, frame->io_len);
|
||||
|
||||
/* Check the required frame size */
|
||||
|
||||
if (frame->io_len > IEEE802154_MAX_PHY_PACKET_SIZE)
|
||||
{
|
||||
return -E2BIG;
|
||||
}
|
||||
{
|
||||
return -E2BIG;
|
||||
}
|
||||
|
||||
/* Cast the first two bytes of the IOB to a uint16_t frame control field */
|
||||
|
||||
@@ -226,10 +229,9 @@ int mac802154_req_data(MACHANDLE mac,
|
||||
* here that created the header
|
||||
*/
|
||||
|
||||
wlinfo("mhr_len=%u\n", mhr_len);
|
||||
DEBUGASSERT(mhr_len == frame->io_offset);
|
||||
|
||||
frame->io_offset = 0; /* Set the offset to 0 to include the header */
|
||||
|
||||
/* Allocate the txdesc, waiting if necessary, allow interruptions */
|
||||
|
||||
ret = mac802154_txdesc_alloc(priv, &txdesc, true);
|
||||
@@ -243,6 +245,16 @@ int mac802154_req_data(MACHANDLE mac,
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Set the offset to 0 to include the header ( we do not want to
|
||||
* modify the frame until AFTER the last place that -EINTR could
|
||||
* be returned and could generate a retry. Subsequent error returns
|
||||
* are fatal and no retry should occur.
|
||||
*/
|
||||
|
||||
frame->io_offset = 0;
|
||||
|
||||
/* Then initialize the TX descriptor */
|
||||
|
||||
txdesc->conf->handle = meta->msdu_handle;
|
||||
txdesc->frame = frame;
|
||||
txdesc->frametype = IEEE802154_FRAME_DATA;
|
||||
@@ -269,7 +281,7 @@ int mac802154_req_data(MACHANDLE mac,
|
||||
*/
|
||||
|
||||
ret = -ENOTSUP;
|
||||
goto errout_with_sem;
|
||||
goto errout_with_txdesc;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -306,7 +318,7 @@ int mac802154_req_data(MACHANDLE mac,
|
||||
else
|
||||
{
|
||||
ret = -EINVAL;
|
||||
goto errout_with_sem;
|
||||
goto errout_with_txdesc;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -327,6 +339,9 @@ int mac802154_req_data(MACHANDLE mac,
|
||||
|
||||
return OK;
|
||||
|
||||
errout_with_txdesc:
|
||||
/* REVISIT: Free TX descriptor, but preserve the IOB. */
|
||||
|
||||
errout_with_sem:
|
||||
mac802154_givesem(&priv->exclsem);
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user