Index: src/linkgraph/linkgraphschedule.cpp
===================================================================
--- src/linkgraph/linkgraphschedule.cpp (revision 27177)
+++ src/linkgraph/linkgraphschedule.cpp (working copy)
@@ -134,11 +134,17 @@
}
/**
+ * Static instance of LinkGraphSchedule.
+ * This declaration cannot be inside Instance(), as that would create
+ * it on first call, which results in a data race between the threads.
+ */
+/* static */ LinkGraphSchedule LinkGraphSchedule::inst;
+
+/**
* Retrieve the link graph schedule or create it if necessary.
*/
/* static */ LinkGraphSchedule *LinkGraphSchedule::Instance()
{
- static LinkGraphSchedule inst;
return &inst;
}
Index: src/linkgraph/linkgraphschedule.h
===================================================================
--- src/linkgraph/linkgraphschedule.h (revision 27177)
+++ src/linkgraph/linkgraphschedule.h (working copy)
@@ -43,6 +43,8 @@
typedef std::list<LinkGraphJob *> JobList;
friend const SaveLoad *GetLinkGraphScheduleDesc();
+ static LinkGraphSchedule inst;
+
protected:
ComponentHandler *handlers[6]; ///< Handlers to be run for each job.
GraphList schedule; ///< Queue for new jobs.
Index: src/linkgraph/mcf.cpp
===================================================================
--- src/linkgraph/mcf.cpp (revision 27177)
+++ src/linkgraph/mcf.cpp (working copy)
@@ -368,6 +368,13 @@
}
/**
+ * Static instance of an invalid path.
+ * This declaration cannot be inside EliminateCycles(), as that would create
+ * it on first call, which results in a data race between the threads.
+ */
+static Path *_invalid_path = new Path(INVALID_NODE, true);
+
+/**
* Eliminate cycles for origin_id in the graph. Start searching at next_id and
* work recursively. Also "summarize" paths: Add up the flows along parallel
* paths in one.
@@ -378,11 +385,10 @@
*/
bool MCF1stPass::EliminateCycles(PathVector &path, NodeID origin_id, NodeID next_id)
{
- static Path *invalid_path = new Path(INVALID_NODE, true);
Path *at_next_pos = path[next_id];
/* this node has already been searched */
- if (at_next_pos == invalid_path) return false;
+ if (at_next_pos == _invalid_path) return false;
if (at_next_pos == NULL) {
/* Summarize paths; add up the paths with the same source and next hop
@@ -430,7 +436,7 @@
* could be found in this branch, thus it has to be searched again next
* time we spot it.
*/
- path[next_id] = found ? NULL : invalid_path;
+ path[next_id] = found ? NULL : _invalid_path;
return found;
}