[Live-devel] triggerEvent() race condition

Ross Finlayson finlayson at live555.com
Mon Mar 16 03:18:14 PDT 2015


> But I can't see how the implementation of triggerEvent() can be thread safe, e.g, the last line:
> 
> fTriggersAwaitingHandling |= eventTriggerId;
> 
> must load, modify and store the value at fTriggersAwaitingHandling

It depends on the CPU architecture.  In many (if not most?) architectures, it’ll just be a single instruction.

I’d put a mutex around that instruction, if there were a good portable way of doing so (i.e., portable across Unix and Windows, and across both old and new compiler versions).

Feel free to put a mutex around your call to “triggerEvent()” - to see if that solves your problem.  (In fact, you should have done that first, before speculating on this mailing list :-)


Ross Finlayson
Live Networks, Inc.
http://www.live555.com/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20150316/2a116978/attachment.html>


More information about the live-devel mailing list