summaryrefslogtreecommitdiff
path: root/test/ipa/ipa_interface_test.cpp
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-11-27 04:18:38 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-11-27 19:30:48 +0200
commite54e9ebff4293c2bcacac4ecb10af8b29480fba9 (patch)
tree702e78306aa3917b4557fc411a892428eb7f9e36 /test/ipa/ipa_interface_test.cpp
parentd9dac46e6f7c1bfbb76daa016fd7aaa580026d70 (diff)
libcamera: thread: Fix race condition when dispatching messages
The Object class stores the number of pending messages that have been posted for it, while the actual messages are stored in a per-thread list in the ThreadData class. When dispatching messages, the message is removed from the list, passed to the receiver, and the number of pending messages is updated. In order to avoid too much contention on the list lock, the lock is dropped to pass the message to the receiver and then taken again. This creates a race condition window with Thread::removeMessages(), as the number of pending messages for a receiver is briefly out of sync with the pending messages list. The assertion at the end of removeMessages() thus sometimes fails. Fix this by decrementing the pending messages counter before releasing the lock in Thread::dispatchMessages(). This fixes the slow message receiver test in MessageTest. Fixes: 01b930964acd ("libcamera: thread: Add a messaging passing API") Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Diffstat (limited to 'test/ipa/ipa_interface_test.cpp')
0 files changed, 0 insertions, 0 deletions