Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

oscpack / udpSocket: invert the "break_" semaphore #7963

Merged
merged 2 commits into from
May 15, 2024

Conversation

artificiel
Copy link
Contributor

In the oscpack udpSocket listener thread there is a flag named break_ which breaks the endless loop, resolving into the thread exiting "properly". because of the threading approach of ofxOscReceiver being changed from detach() to join(), a new race condition emerges: in the close() of the ofxOscSender the asynchronousBreak() function is called, which sets the flag to true in order to break the listener, but there are cases where the listener thread has not spun up yet, but will be forced to by the join(), and the first thing it does in Run() is to reset break_ to false, this removing the flag and creating the hang (the Run() will never return).

this changes inverses the logic: the break_ is initialized to false, and changed back to false at the end of Run(). this way if it's changed to true before the thread start, the thread immediately stops. resetting the flag to false makes the object reusable (even though the ofxOscReceiver pattern will re-create a new object when re-started())

(note: the volatile bool is also upgraded to std::atomic<bool>)

this solves the INSTANTLY_OUT_OF_SCOPE test case documented in #7949

@ofTheo
Copy link
Member

ofTheo commented May 15, 2024

Thanks @artificiel !

@ofTheo ofTheo merged commit cd21c01 into openframeworks:master May 15, 2024
11 checks passed
danoli3 added a commit to danoli3/openFrameworks that referenced this pull request May 20, 2024
…leedingmacOS

* commit '7f37e70f65e9e022ba8868fb555570ce2c78a6ba': (37 commits)
  Allows Retina hi res enabled via App or Project.xcconfig (openframeworks#7971)
  actions changes (openframeworks#7968)
  Changing exr to hdr files for compatability with windows (openframeworks#7964)
  ofMesh - newfaces push_back to insert a list (openframeworks#7772)
  restore default-copy-constructibility of ofEvent (openframeworks#7969)
  [actions] ccache update (openframeworks#7967)
  Core small changes (openframeworks#7952)
  config.emscripten.default.mk for Emscripten >= 3.1.52 (openframeworks#7909)
  Fix edge case in findDelimiter (openframeworks#7911)
  oscpack / udpSocket: invert the "break_" semaphore (openframeworks#7963)
  ofxOscMessage: extra implicit adds [fixes something noted through openframeworks#7938 debugging] (openframeworks#7953) #changelog #ofxOsc
  ofThreadChannel::clear() to clear the channel (openframeworks#7921) #changelog #threadChannel
  OfxOscReceiver: from detach() to join() (openframeworks#7949)
  Update ofMathConstants.h (openframeworks#7958)
  [actions] update ubuntu 24.04 (openframeworks#7955)
  ofScopedMatrix (openframeworks#7946)
  [actions] - testing one action with multiple jobs for tests (openframeworks#7860)
  adding of.entitlements and vscode files to gitignore (openframeworks#7031)
  Make - use relative paths (openframeworks#7519)
  FPS timing with chrono (openframeworks#7867)
  ...

# Conflicts:
#	libs/openFrameworks/sound/ofAVEngineSoundPlayer.mm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants