Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Köplinger <alex.koeplinger@outlook.com>2015-03-05 05:46:50 +0300
committerAlexander Köplinger <alex.koeplinger@outlook.com>2015-03-05 05:46:50 +0300
commitaeffabc10fd8c6fed4a35fbc94b0f664dded6072 (patch)
treea016703966ed7c7f87ed582110ea9fc5f3202eb2 /mcs/class/Microsoft.Build.Engine
parent6fdc2ecf078d5ea557945555fe37bc415936e64f (diff)
[Microsoft.Build.Enginge] Fix race in ConsoleLogger
This occasionally made the BasicManualParallelBuilds test fail on Jenkins.
Diffstat (limited to 'mcs/class/Microsoft.Build.Engine')
-rw-r--r--mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ConsoleLogger.cs11
1 files changed, 4 insertions, 7 deletions
diff --git a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ConsoleLogger.cs b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ConsoleLogger.cs
index d0dcf340a7d..6226199b725 100644
--- a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ConsoleLogger.cs
+++ b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ConsoleLogger.cs
@@ -28,6 +28,7 @@
using System;
using System.Runtime.InteropServices;
using System.Collections;
+using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -277,7 +278,7 @@ namespace Microsoft.Build.BuildEngine
ParseParameters ();
}
- Dictionary<object,BuildRecord> build_records = new Dictionary<object, BuildRecord> ();
+ ConcurrentDictionary<object,BuildRecord> build_records = new ConcurrentDictionary<object, BuildRecord> ();
object dummy_key = new object ();
@@ -292,11 +293,7 @@ namespace Microsoft.Build.BuildEngine
// only Microsoft.Build.Internal.BuildEngine4 implements it so far.
// (Used IBuildEngine3 because it needs to build for NET_4_0).
var key = sender as IBuildEngine3 ?? dummy_key;
- if (!build_records.TryGetValue (key, out r)) {
- r = new BuildRecord (this);
- build_records.Add (key, r);
- }
- return r;
+ return build_records.GetOrAdd (key, _ => new BuildRecord (this));
}
public void BuildStartedHandler (object sender, BuildStartedEventArgs args)
@@ -307,7 +304,7 @@ namespace Microsoft.Build.BuildEngine
public void BuildFinishedHandler (object sender, BuildFinishedEventArgs args)
{
GetBuildRecord (sender).BuildFinishedHandler (args);
- build_records.Remove (sender);
+ ((IDictionary) build_records).Remove (sender);
}
void PushEvent<T> (object sender, T args) where T: BuildStatusEventArgs