lib/platform/linux/platform.c: polling thread accesses indication queue variables without mutex held
While doing upgrade from earlier WPC API library to c-mesh-api/master, we noticed this issue during code review.
In lib/platform/linux/platform.c, dispatch queue accesses indication queue with m_queue_mutex held. However, polling thread is accessing indication queue variables without taking mutex, for example at https://github.com/wirepas/c-mesh-api/blob/master/lib/platform/linux/platform.c#L177
Sorry for late reply.
I don't think there is a real issue here. The only two parts where the queue is accessed is dispatch_indication for read access (https://github.com/wirepas/c-mesh-api/blob/master/lib/platform/linux/platform.c#L86) and onIndicationReceivedLocked for write access (https://github.com/wirepas/c-mesh-api/blob/master/lib/platform/linux/platform.c#L125)
But I agree that in poll_for_indication (https://github.com/wirepas/c-mesh-api/blob/master/lib/platform/linux/platform.c#L169) it would be cleaner to held the mutex also when computing the queue size. But the size is more informative here.
Only risk is to underestimate the free space and it is not an issue.