Skip to content

Make MDClientCtx thread-safe #325

Description

@frankosterfeld

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions