Loading

Paste #pt9yiclmt

  1. Index: src/linkgraph/linkgraphschedule.cpp
  2. ===================================================================
  3. --- src/linkgraph/linkgraphschedule.cpp (revision 27177)
  4. +++ src/linkgraph/linkgraphschedule.cpp (working copy)
  5. @@ -134,11 +134,17 @@
  6.  }
  7.  
  8.  /**
  9. + * Static instance of LinkGraphSchedule.
  10. + * This declaration cannot be inside Instance(), as that would create
  11. + * it on first call, which results in a data race between the threads.
  12. + */
  13. +/* static */ LinkGraphSchedule LinkGraphSchedule::inst;
  14. +
  15. +/**
  16.   * Retrieve the link graph schedule or create it if necessary.
  17.   */
  18.  /* static */ LinkGraphSchedule *LinkGraphSchedule::Instance()
  19.  {
  20. -   static LinkGraphSchedule inst;
  21.     return &inst;
  22.  }
  23.  
  24. Index: src/linkgraph/linkgraphschedule.h
  25. ===================================================================
  26. --- src/linkgraph/linkgraphschedule.h   (revision 27177)
  27. +++ src/linkgraph/linkgraphschedule.h   (working copy)
  28. @@ -43,6 +43,8 @@
  29.     typedef std::list<LinkGraphJob *> JobList;
  30.     friend const SaveLoad *GetLinkGraphScheduleDesc();
  31.  
  32. +   static LinkGraphSchedule inst;
  33. +
  34.  protected:
  35.     ComponentHandler *handlers[6]; ///< Handlers to be run for each job.
  36.     GraphList schedule;            ///< Queue for new jobs.
  37. Index: src/linkgraph/mcf.cpp
  38. ===================================================================
  39. --- src/linkgraph/mcf.cpp   (revision 27177)
  40. +++ src/linkgraph/mcf.cpp   (working copy)
  41. @@ -368,6 +368,13 @@
  42.  }
  43.  
  44.  /**
  45. + * Static instance of an invalid path.
  46. + * This declaration cannot be inside EliminateCycles(), as that would create
  47. + * it on first call, which results in a data race between the threads.
  48. + */
  49. +static Path *_invalid_path = new Path(INVALID_NODE, true);
  50. +
  51. +/**
  52.   * Eliminate cycles for origin_id in the graph. Start searching at next_id and
  53.   * work recursively. Also "summarize" paths: Add up the flows along parallel
  54.   * paths in one.
  55. @@ -378,11 +385,10 @@
  56.   */
  57.  bool MCF1stPass::EliminateCycles(PathVector &path, NodeID origin_id, NodeID next_id)
  58.  {
  59. -   static Path *invalid_path = new Path(INVALID_NODE, true);
  60.     Path *at_next_pos = path[next_id];
  61.  
  62.     /* this node has already been searched */
  63. -   if (at_next_pos == invalid_path) return false;
  64. +   if (at_next_pos == _invalid_path) return false;
  65.  
  66.     if (at_next_pos == NULL) {
  67.         /* Summarize paths; add up the paths with the same source and next hop
  68. @@ -430,7 +436,7 @@
  69.          * could be found in this branch, thus it has to be searched again next
  70.          * time we spot it.
  71.          */
  72. -       path[next_id] = found ? NULL : invalid_path;
  73. +       path[next_id] = found ? NULL : _invalid_path;
  74.         return found;
  75.     }
  76.  
  77.  

Comments