Thread-safety for device descriptor sending in async plugins.#423
Thread-safety for device descriptor sending in async plugins.#423
Conversation
| void OSVR_DeviceTokenObject::setDeviceDescriptor( | ||
| std::string const &jsonString) { | ||
| auto guard = getSendGuard(); | ||
| guard->lock(); |
There was a problem hiding this comment.
Do we need to call unlock() or does a destructor take care of that? (I gave up tracing through the code after 10 minutes.)
|
It's a guard class - so raii handles the unlock. It just needs a manual lock because it's polymorphic and the actual guard, if applicable, is returned, not a lockable object. (Tracing it shouldn't be that hard, think it's just guard interface in util). |
|
The |
|
Well, right, the base class is, since sync devices don't need to pay On Sat, Apr 23, 2016, 3:08 PM Kevin Godby notifications@github.com wrote:
|
I think I hit this in early revisions of the vive plugin - it seems like the original implementation of the device descriptor sending code assumed you'd either only send it once, or you'd be a sync plugin and send from the main thread: there was no send-guard or equiv. locking around the descriptor update but that's definitely not something you want to do in a non-main thread since it can trigger a send.
This hasn't been tested, don't merge it until it has been.