Call taskYIELD after calling FreeRTOS_send in Plaintext_FreeRTOS_send (#491)

FreeRTOS_send adds the packet to be sent to the IP task's queue for
later processing. The packet is sent later by the IP task. When
FreeRTOS is used in collaborative mode (i.e. configUSE_PREEMPTION is 0),
the Plaintext_FreeRTOS_send function returns without actually sending
the packet as the IP task never gets a chance to run.

The fact that Plaintext_FreeRTOS_send returns without actually sending
the packet causes an issue in the MQTT_Connect which expects the CONNECT
packet to be actually sent and waits for CONNACK.

This commit adds a taskYIELD call after calling FreeRTOS_send to ensure
that the IP task gets a chance to run and send the packet before the
Plaintext_FreeRTOS_send function returns.
This commit is contained in:
Marc-Antoine Lalonde 2021-01-25 17:30:42 -05:00 committed by GitHub
parent 748a701b91
commit 52c9756f21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -29,6 +29,9 @@
/* FreeRTOS includes. */
#include "FreeRTOS.h"
#if ( configUSE_PREEMPTION == 0 )
#include "task.h"
#endif
/* FreeRTOS+TCP includes. */
#include "FreeRTOS_IP.h"
@ -182,5 +185,15 @@ int32_t Plaintext_FreeRTOS_send( NetworkContext_t * pNetworkContext,
socketStatus = 0;
}
#if ( configUSE_PREEMPTION == 0 )
{
/* FreeRTOS_send adds the packet to be sent to the IP task's queue for later processing.
* The packet is sent later by the IP task. When FreeRTOS is used in collaborative
* mode (i.e. configUSE_PREEMPTION is 0), call taskYIELD to give IP task a chance to run
* so that the packet is actually sent before this function returns. */
taskYIELD();
}
#endif
return socketStatus;
}