From 81bcc63259b8749e0532d3c0b8eb16f8d3caf9c5 Mon Sep 17 00:00:00 2001 From: John Hsu Date: Tue, 9 Feb 2010 00:50:38 +0000 Subject: [PATCH] fix possible race condition per ticket #3802 git-svn-id: https://code.ros.org/svn/ros-pkg/stacks/laser_pipeline/trunk@27698 eb33c2ac-9c88-4c90-87e0-44a10359b0c3 --- include/laser_geometry/laser_geometry.h | 2 ++ src/laser_geometry.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/include/laser_geometry/laser_geometry.h b/include/laser_geometry/laser_geometry.h index f58d4b1..8610915 100644 --- a/include/laser_geometry/laser_geometry.h +++ b/include/laser_geometry/laser_geometry.h @@ -35,6 +35,7 @@ #include #include "boost/numeric/ublas/matrix.hpp" +#include "boost/thread/mutex.hpp" #include "tf/tf.h" @@ -234,6 +235,7 @@ namespace laser_geometry //! Internal map of pointers to stored values std::map* > unit_vector_map_; + boost::mutex guv_mutex_; }; } diff --git a/src/laser_geometry.cpp b/src/laser_geometry.cpp index a2ed1e1..ab60bb5 100644 --- a/src/laser_geometry.cpp +++ b/src/laser_geometry.cpp @@ -152,6 +152,8 @@ namespace laser_geometry const boost::numeric::ublas::matrix& LaserProjection::getUnitVectors_(double angle_min, double angle_max, double angle_increment, unsigned int length) { + boost::mutex::scoped_lock guv_lock(this->guv_mutex_); + //construct string for lookup in the map std::stringstream anglestring; anglestring <