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

Make MDClientCtx thread-safe #325

Open
frankosterfeld opened this issue Oct 25, 2023 · 0 comments
Open

Make MDClientCtx thread-safe #325

frankosterfeld opened this issue Oct 25, 2023 · 0 comments

Comments

@frankosterfeld
Copy link
Contributor

MDClientCtx has some threading issues:

The use of the poller thread calling poll() is not thread-safe:

  • _pollItems is accessed from the thread without synchronization, that can crash when the MDClient is destroyed while the thread is running. _pollItems is also modified in disconnect()
  • Other members such as _subscriptions and _requests are accessed without synchronization.
  • I think there should be an explicit poller->request_stop(); poller->join() in ~MDClientCtx

While at it:
if (_subscriptions.contains(receivedEvent.serviceName)) {
_subscriptions.at(receivedEvent.serviceName).callback(receivedEvent); // callback
}
can be replaced by a single lookup (find()) instead of two. Same for _requests below.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 📋 Backlog
Development

No branches or pull requests

3 participants