Skip to content

Commit

Permalink
FIx bad thread join.
Browse files Browse the repository at this point in the history
  • Loading branch information
GhostofCookie committed Jun 3, 2024
1 parent e3ea500 commit 93eda5e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 5 additions & 3 deletions src/quicr_client_raw_session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ ClientRawSession::~ClientRawSession()
disconnect();
}

_metrics_thread.join();
if (_metrics_thread.joinable()) {
_metrics_thread.join();
}
}

bool
Expand Down Expand Up @@ -1018,7 +1020,7 @@ ClientRawSession::handle(std::optional<uint64_t> stream_id,
<< std::flush;

if (metrics_namespace) {
publishIntent(std::make_shared<MetricsPublishDelegate>(*this),
publishIntent(std::make_shared<MetricsPublishDelegate>([this] { this->runPublishMeasurements(); }),
*metrics_namespace,
"",
"",
Expand Down Expand Up @@ -1198,6 +1200,6 @@ ClientRawSession::MetricsPublishDelegate::onPublishIntentResponse(
if (result.status != messages::Response::Ok)
return;

session.runPublishMeasurements();
start_metrics_callback();
}
} // namespace quicr
5 changes: 3 additions & 2 deletions src/quicr_client_raw_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <transport/transport.h>

#include <atomic>
#include <functional>
#include <map>
#include <memory>
#include <string>
Expand Down Expand Up @@ -366,11 +367,11 @@ class ClientRawSession

struct MetricsPublishDelegate : public PublisherDelegate
{
MetricsPublishDelegate(ClientRawSession& s) : session{s} {}
MetricsPublishDelegate(const std::function<void()>& cb) : start_metrics_callback{cb} {}
void onPublishIntentResponse(const quicr::Namespace& quicr_namespace,
const PublishIntentResult& result) override;

ClientRawSession& session;
std::function<void()> start_metrics_callback;
};
friend MetricsPublishDelegate;

Expand Down

0 comments on commit 93eda5e

Please sign in to comment.