From c09b643d8d5f7eeaecbdfbe3152f8e337d3e2f0b Mon Sep 17 00:00:00 2001 From: Wolfgang Hess Date: Tue, 13 Mar 2018 14:10:51 +0100 Subject: [PATCH] Synchronize correctly in FinishTrajectory(). (#980) PoseGraph{2D,3D}::FinishTrajectory() calls AddWorkItem() which requires the mutex to be held. This adds code to do this. --- cartographer/mapping/internal/2d/pose_graph_2d.cc | 1 + cartographer/mapping/internal/3d/pose_graph_3d.cc | 1 + 2 files changed, 2 insertions(+) diff --git a/cartographer/mapping/internal/2d/pose_graph_2d.cc b/cartographer/mapping/internal/2d/pose_graph_2d.cc index 5f12521..79862a6 100644 --- a/cartographer/mapping/internal/2d/pose_graph_2d.cc +++ b/cartographer/mapping/internal/2d/pose_graph_2d.cc @@ -392,6 +392,7 @@ void PoseGraph2D::WaitForAllComputations() { } void PoseGraph2D::FinishTrajectory(const int trajectory_id) { + common::MutexLocker locker(&mutex_); AddWorkItem([this, trajectory_id]() REQUIRES(mutex_) { CHECK_EQ(finished_trajectories_.count(trajectory_id), 0); finished_trajectories_.insert(trajectory_id); diff --git a/cartographer/mapping/internal/3d/pose_graph_3d.cc b/cartographer/mapping/internal/3d/pose_graph_3d.cc index e9cc96d..7c81fd8 100644 --- a/cartographer/mapping/internal/3d/pose_graph_3d.cc +++ b/cartographer/mapping/internal/3d/pose_graph_3d.cc @@ -410,6 +410,7 @@ void PoseGraph3D::WaitForAllComputations() { } void PoseGraph3D::FinishTrajectory(const int trajectory_id) { + common::MutexLocker locker(&mutex_); AddWorkItem([this, trajectory_id]() REQUIRES(mutex_) { CHECK_EQ(finished_trajectories_.count(trajectory_id), 0); finished_trajectories_.insert(trajectory_id);