Skip to content

Commit 3e2191e

Browse files
committed
Fix functions broken by nested mutex feature
1 parent db3c2fb commit 3e2191e

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

FreeRTOS/queue.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,14 @@ UBaseType_t uxQueueMessagesWaiting( const QueueHandle_t xQueue )
569569

570570
if ( type == RT_Object_Class_Mutex )
571571
{
572-
uxReturn = ( ( rt_mutex_t ) pipc )->value;
572+
if ( ( ( rt_mutex_t ) pipc )->owner == RT_NULL )
573+
{
574+
uxReturn = 1;
575+
}
576+
else
577+
{
578+
uxReturn = 0;
579+
}
573580
}
574581
else if ( type == RT_Object_Class_Semaphore )
575582
{
@@ -603,7 +610,14 @@ UBaseType_t uxQueueSpacesAvailable( const QueueHandle_t xQueue )
603610

604611
if ( type == RT_Object_Class_Mutex )
605612
{
606-
uxReturn = 1 - ( ( rt_mutex_t ) pipc )->value;
613+
if ( ( ( rt_mutex_t ) pipc )->owner == RT_NULL )
614+
{
615+
uxReturn = 0;
616+
}
617+
else
618+
{
619+
uxReturn = 1;
620+
}
607621
}
608622
else if ( type == RT_Object_Class_Semaphore )
609623
{

0 commit comments

Comments
 (0)