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:
authorMiguel de Icaza <miguel@gnome.org>2015-02-20 19:23:50 +0300
committerMiguel de Icaza <miguel@gnome.org>2015-02-20 19:23:50 +0300
commit0e8701a161c0c7064ddaee0e3284b40eae3f07cd (patch)
treef765e9c6f4ad11cd28a5ad00b6df623b752629c3
parent6800659e8cd7002d62892eacddbdd196f97a2e9e (diff)
parentb3ddd74efbf6f453a30001b16ec519021a6f15f0 (diff)
Merge pull request #1582 from zevane/patch-1
Make the class thread-safe
-rw-r--r--mcs/class/System.Configuration/System.Configuration/ConfigurationSectionCollection.cs21
1 files changed, 12 insertions, 9 deletions
diff --git a/mcs/class/System.Configuration/System.Configuration/ConfigurationSectionCollection.cs b/mcs/class/System.Configuration/System.Configuration/ConfigurationSectionCollection.cs
index 5b0f531e55d..925fb547eba 100644
--- a/mcs/class/System.Configuration/System.Configuration/ConfigurationSectionCollection.cs
+++ b/mcs/class/System.Configuration/System.Configuration/ConfigurationSectionCollection.cs
@@ -39,7 +39,8 @@ namespace System.Configuration
{
SectionGroupInfo group;
Configuration config;
-
+ static readonly object lockObject = new object();
+
internal ConfigurationSectionCollection (Configuration config, SectionGroupInfo group)
: base (StringComparer.Ordinal)
{
@@ -60,15 +61,17 @@ namespace System.Configuration
public ConfigurationSection this [string name]
{
get {
- 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;
- BaseSet (name, sec);
+ 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;
+ BaseSet (name, sec);
+ }
+ return sec;
}
- return sec;
}
}