Skip to content

Commit

Permalink
Merge pull request #582 from j-oberlaender/master
Browse files Browse the repository at this point in the history
PCDGrabberImpl: Add mutex to avoid reentry in trigger()/readAhead() and the resulting race condition.
  • Loading branch information
jspricke committed Mar 29, 2014
2 parents 70a9b93 + 1a5603c commit 73b8d14
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions io/src/pcd_grabber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ struct pcl::PCDGrabberBase::PCDGrabberImpl
std::vector<int> tar_offsets_;
std::vector<size_t> cloud_idx_to_file_idx_;

// Mutex to ensure that two quick consecutive triggers do not cause
// simultaneous asynchronous read-aheads
boost::mutex read_ahead_mutex_;

EIGEN_MAKE_ALIGNED_OPERATOR_NEW
};

Expand Down Expand Up @@ -282,6 +286,7 @@ pcl::PCDGrabberBase::PCDGrabberImpl::openTARFile (const std::string &file_name)
void
pcl::PCDGrabberBase::PCDGrabberImpl::trigger ()
{
boost::mutex::scoped_lock read_ahead_lock(read_ahead_mutex_);
if (valid_)
grabber_.publish (next_cloud_,origin_,orientation_);

Expand Down

0 comments on commit 73b8d14

Please sign in to comment.