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

No pthread_cancel() on Android #1308

Merged
merged 1 commit into from
Jun 18, 2019

Conversation

dandrader
Copy link

  • If you are contributing a new feature, is your work based off the develop branch?
  • If you are contributing a bugfix, is your work based off the fixes branch?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you successfully run make test with your changes locally?
  • Have you signed the Eclipse Contributor Agreement, using the same email address as you used in your commits?
  • Do each of your commits have a "Signed-off-by" line, with the correct email address? Use "git commit -s" to generate this line for you.

pthread_cancel() is not available on Android

Thus mosquitto_loop_start() and mosquitto_loop_stop() won't be available there (and mosquitto_connect_async() as a consequence).

Thus mosquitto_loop_start() and mosquitto_loop_stop()
won't be available there (and mosquitto_connect_async()
as a consequence).

Signed-off-by: Daniel d'Andrada <[email protected]>
ralight added a commit that referenced this pull request Jun 18, 2019
It doesn't support pthread_cancel.

Closes #1308. Thanks to Daniel d'Andrada.
@ralight
Copy link
Contributor

ralight commented Jun 18, 2019

Thanks for this Dan, I wasn't aware of that problem on Android. I hope you don't mind, I've fixed this in a slightly simpler fashion in the commit I've just pushed to fixes.

@dandrader
Copy link
Author

Hi Robert,

Please correct me if I'm wrong, but If you unset WITH_THREADING then the mutexes won't be operational and therefore the API will no longer be thread-safe, right?

In my usage I'm running mosquitto_loop() in one thread, and the rest of the API in another one. Without calling mosquitto_threaded_set(... true) I get the obscure crashes mentioned in its documentation.

Disabling just the pthread_cancel usage, like I did in this patch, you lose the mosquitto_connect_async API but still keep using real mutexes to guard the internal data structures.

Will mosquitto_threaded_set(... true) still keep its promises without WITH_THREADING defined?

@ralight
Copy link
Contributor

ralight commented Jun 18, 2019

You make a good point, let's go with your solution instead.

@ralight ralight merged commit be09731 into eclipse:fixes Jun 18, 2019
@nihilus
Copy link

nihilus commented Jan 2, 2020

Actually bionic libc lacks pthread_cancel() as you've figured out; it requires stack unwinding and is to be considered a "hack" in most libc-implementations (no safe cancellation points), however for mosquitto I personally find waiting for pthread_join() more feasible than disable threading. Code based on the async-API won't be able to run on Android which is a pity.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants