From ee948a88108fcafe5fc45fff0a38a5f591b1eb17 Mon Sep 17 00:00:00 2001 From: Patrick Brosi Date: Mon, 13 May 2019 15:05:34 +0200 Subject: [PATCH] prevent possible race condition while obtaining collision-free shape ID --- src/pfaedle/router/ShapeBuilder.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pfaedle/router/ShapeBuilder.cpp b/src/pfaedle/router/ShapeBuilder.cpp index ffc56f2..b96f8a6 100644 --- a/src/pfaedle/router/ShapeBuilder.cpp +++ b/src/pfaedle/router/ShapeBuilder.cpp @@ -242,6 +242,7 @@ void ShapeBuilder::shape(pfaedle::netgraph::Graph* ng) { for (auto t : clusters[i]) { if (_cfg.evaluate && _evalFeed && _ecoll) { + std::lock_guard guard(_shpMutex); _ecoll->add(t, _evalFeed->getShapes().get(t->getShape()), shp, distances); } @@ -249,6 +250,7 @@ void ShapeBuilder::shape(pfaedle::netgraph::Graph* ng) { if (!t->getShape().empty() && shpUsage[t->getShape()] > 0) { shpUsage[t->getShape()]--; if (shpUsage[t->getShape()] == 0) { + std::lock_guard guard(_shpMutex); _feed->getShapes().remove(t->getShape()); } } @@ -289,7 +291,6 @@ void ShapeBuilder::setShape(Trip* t, const ad::cppgtfs::gtfs::Shape& s, } std::lock_guard guard(_shpMutex); - // TODO(patrick): t->setShape(_feed->getShapes().add(s)); }