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:
authorzevane <juancgall@gmail.com>2015-02-20 22:04:01 +0300
committerzevane <juancgall@gmail.com>2015-02-20 22:04:01 +0300
commit4751c10f9c7100ce525640561f418221074d4f50 (patch)
tree68ebb288b74866c11293b4ed500ff0e82fe046fa /mcs/class/System.Configuration
parent2202e97c33179f31a72abc80fd04e6495052f420 (diff)
Limit the lock to the writing operation
I initially discarded this change, because locking BaseSet (name, sec), didn't prevent the threads from trying to add the same key. That said, following the code, the point at which it actually fails is in NameObjectCollectionBase.BaseAdd, lines 331 and 332. The threads were arriving the second line at the same time: if (_entriesTable[name] == null) _entriesTable.Add(name, entry); In brief, it's safe to call BaseSet twice with the same key, so it's safe to lock only the call to BaseSet
Diffstat (limited to 'mcs/class/System.Configuration')
-rw-r--r--mcs/class/System.Configuration/System.Configuration/ConfigurationSectionCollection.cs16
1 files changed, 8 insertions, 8 deletions
diff --git a/mcs/class/System.Configuration/System.Configuration/ConfigurationSectionCollection.cs b/mcs/class/System.Configuration/System.Configuration/ConfigurationSectionCollection.cs
index 925fb547eba..307fb997de7 100644
--- a/mcs/class/System.Configuration/System.Configuration/ConfigurationSectionCollection.cs
+++ b/mcs/class/System.Configuration/System.Configuration/ConfigurationSectionCollection.cs
@@ -61,17 +61,17 @@ namespace System.Configuration
public ConfigurationSection this [string name]
{
get {
- lock(lockObject) {
- ConfigurationSection sec = BaseGet (name) as ConfigurationSection;
- if (sec == null) {
- SectionInfo secData = group.Sections [name] as SectionInfo;
- if (secData == null) return null;
- sec = config.GetSectionInstance (secData, true);
- if (sec == null) return null;
+ ConfigurationSection sec = BaseGet (name) as ConfigurationSection;
+ if (sec == null) {
+ SectionInfo secData = group.Sections [name] as SectionInfo;
+ if (secData == null) return null;
+ sec = config.GetSectionInstance (secData, true);
+ if (sec == null) return null;
+ lock(lockObject) {
BaseSet (name, sec);
}
- return sec;
}
+ return sec;
}
}