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.
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()poller->request_stop(); poller->join()
in ~MDClientCtxWhile 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.