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
path: root/mcs/class
diff options
context:
space:
mode:
authorBen Maurer <benm@mono-cvs.ximian.com>2005-05-27 03:06:52 +0400
committerBen Maurer <benm@mono-cvs.ximian.com>2005-05-27 03:06:52 +0400
commit2a81dac63f6590d7556a61fc1169a6d3d2a5cb29 (patch)
treef6f43c912f048fccdc2bca1c18df29fd92ab10c0 /mcs/class
parent270cf818cff0e56f7e346e5f914cdeb864bcb736 (diff)
locking fixes
svn path=/trunk/mcs/; revision=45085
Diffstat (limited to 'mcs/class')
-rw-r--r--mcs/class/Mono.Cairo/Mono.Cairo/Surface.cs6
-rwxr-xr-xmcs/class/Mono.Security/Mono.Security.Cryptography/KeyPairPersistence.cs10
-rw-r--r--mcs/class/System.Data/System.Data.Odbc/OdbcConnectionFactory.cs3
-rw-r--r--mcs/class/System.Data/System.Data.Odbc/OdbcFactory.cs39
-rw-r--r--mcs/class/System.Data/System.Data.Odbc/OdbcTypeConverter.cs55
-rw-r--r--mcs/class/System.Data/System.Data.SqlClient/SqlConnectionFactory.cs21
-rw-r--r--mcs/class/System.Web/System.Web.Configuration/WebConfigurationSettings.cs7
-rw-r--r--mcs/class/System.Web/System.Web.Configuration/WebControlsSectionHandler.cs5
-rw-r--r--mcs/class/System.Web/System.Web/CapabilitiesLoader.cs33
9 files changed, 84 insertions, 95 deletions
diff --git a/mcs/class/Mono.Cairo/Mono.Cairo/Surface.cs b/mcs/class/Mono.Cairo/Mono.Cairo/Surface.cs
index 96e3cb68b4b..4fb2db8a60a 100644
--- a/mcs/class/Mono.Cairo/Mono.Cairo/Surface.cs
+++ b/mcs/class/Mono.Cairo/Mono.Cairo/Surface.cs
@@ -48,7 +48,7 @@ namespace Cairo {
private Surface (IntPtr ptr, bool owns)
{
surface = ptr;
- lock (typeof (Surface)){
+ lock (surfaces.SyncRoot){
surfaces [ptr] = this;
}
if (!owns)
@@ -57,7 +57,7 @@ namespace Cairo {
static internal Surface LookupExternalSurface (IntPtr p)
{
- lock (typeof (Surface)){
+ lock (surfaces.SyncRoot){
object o = surfaces [p];
if (o == null){
return new Surface (p, false);
@@ -124,7 +124,7 @@ namespace Cairo {
{
if (surface == (IntPtr) 0)
return;
- lock (typeof (Surface)){
+ lock (surfaces.SyncRoot){
surfaces.Remove (surface);
}
CairoAPI.cairo_surface_destroy (surface);
diff --git a/mcs/class/Mono.Security/Mono.Security.Cryptography/KeyPairPersistence.cs b/mcs/class/Mono.Security/Mono.Security.Cryptography/KeyPairPersistence.cs
index c0e748339cd..ad43b08c495 100755
--- a/mcs/class/Mono.Security/Mono.Security.Cryptography/KeyPairPersistence.cs
+++ b/mcs/class/Mono.Security/Mono.Security.Cryptography/KeyPairPersistence.cs
@@ -201,10 +201,12 @@ namespace Mono.Security.Cryptography {
// private static stuff
+ static object lockobj = new object ();
+
private static string UserPath {
get {
- if ((_userPath == null) || (!_userPathExists)) {
- lock (typeof (KeyPairPersistence)) {
+ lock (lockobj) {
+ if ((_userPath == null) || (!_userPathExists)) {
_userPath = Path.Combine (
Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData),
".mono");
@@ -235,8 +237,8 @@ namespace Mono.Security.Cryptography {
private static string MachinePath {
get {
- if ((_machinePath == null) || (!_machinePathExists)) {
- lock (typeof (KeyPairPersistence)) {
+ lock (lockobj) {
+ if ((_machinePath == null) || (!_machinePathExists)) {
_machinePath = Path.Combine (
Environment.GetFolderPath (Environment.SpecialFolder.CommonApplicationData),
".mono");
diff --git a/mcs/class/System.Data/System.Data.Odbc/OdbcConnectionFactory.cs b/mcs/class/System.Data/System.Data.Odbc/OdbcConnectionFactory.cs
index 7819b14fc2b..f60ae55b738 100644
--- a/mcs/class/System.Data/System.Data.Odbc/OdbcConnectionFactory.cs
+++ b/mcs/class/System.Data/System.Data.Odbc/OdbcConnectionFactory.cs
@@ -39,6 +39,7 @@ namespace System.Data.Odbc {
#region Fields
internal static OdbcConnectionFactory Instance; // singleton
private static DbProviderFactory _providerFactory;
+ static readonly object lockobj = new object ();
#endregion // Fields
#region Constructors
@@ -61,7 +62,7 @@ namespace System.Data.Odbc {
// create singleton connection factory.
internal static OdbcConnectionFactory GetSingleton (OdbcFactory pvdrFactory)
{
- lock (typeof (OdbcConnectionFactory))
+ lock (lockobj)
{
if (Instance == null)
Instance = new OdbcConnectionFactory (pvdrFactory);
diff --git a/mcs/class/System.Data/System.Data.Odbc/OdbcFactory.cs b/mcs/class/System.Data/System.Data.Odbc/OdbcFactory.cs
index 90b95c3e6aa..482f3435f9a 100644
--- a/mcs/class/System.Data/System.Data.Odbc/OdbcFactory.cs
+++ b/mcs/class/System.Data/System.Data.Odbc/OdbcFactory.cs
@@ -43,30 +43,27 @@ namespace System.Data.Odbc
{
#region Fields
public static readonly OdbcFactory Instance;
+ static readonly object lockobj = new object ();
#endregion //Fields
#region Constructors
- /// <remarks>
- /// public static variable Instance should hold the the singleton instance
- /// based on the knowledge that custom factories without this instance variable
- /// ms.net throws exception
- /// <pre>
- /// System.InvalidOperationException: The requested .Net Framework Data
- /// Provider's implementation does not have an Instance field
- /// of a System.Data.Common.DbProviderFactory derived type.
- /// at System.Data.Common.DbProviderFactories.GetFactory(DataRow providerRow)
- /// at System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName)
- /// </pre>
- /// </remarks>
- static OdbcFactory()
- {
- lock (typeof (OdbcFactory))
- {
- if (Instance == null)
- Instance = new OdbcFactory ();
- }
-
- }
+ /// <remarks>
+ /// public static variable Instance should hold the the singleton instance
+ /// based on the knowledge that custom factories without this instance variable
+ /// ms.net throws exception
+ /// <pre>
+ /// System.InvalidOperationException: The requested .Net Framework Data
+ /// Provider's implementation does not have an Instance field
+ /// of a System.Data.Common.DbProviderFactory derived type.
+ /// at System.Data.Common.DbProviderFactories.GetFactory(DataRow providerRow)
+ /// at System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName)
+ /// </pre>
+ /// </remarks>
+ static OdbcFactory()
+ {
+ if (Instance == null)
+ Instance = new OdbcFactory ();
+ }
private OdbcFactory()
{
diff --git a/mcs/class/System.Data/System.Data.Odbc/OdbcTypeConverter.cs b/mcs/class/System.Data/System.Data.Odbc/OdbcTypeConverter.cs
index b502c28ffed..c4927688003 100644
--- a/mcs/class/System.Data/System.Data.Odbc/OdbcTypeConverter.cs
+++ b/mcs/class/System.Data/System.Data.Odbc/OdbcTypeConverter.cs
@@ -243,36 +243,31 @@ namespace System.Data.Odbc
static OdbcTypeConverter ()
{
- lock (typeof (OdbcTypeConverter)) {
- if (OdbcTypeMap == null) {
- OdbcTypeMap = new MapCollection ();
- OdbcTypeMap.Add (new TypeMap (OdbcType.BigInt, SQL_C_TYPE.SBIGINT, SQL_TYPE.BIGINT ));
- OdbcTypeMap.Add (new TypeMap (OdbcType.Binary, SQL_C_TYPE.BINARY, SQL_TYPE.BINARY ));
- OdbcTypeMap.Add (new TypeMap (OdbcType.Bit, SQL_C_TYPE.BIT, SQL_TYPE.BIT ));
- OdbcTypeMap.Add (new TypeMap (OdbcType.Char, SQL_C_TYPE.CHAR, SQL_TYPE.CHAR ));
- OdbcTypeMap.Add (new TypeMap (OdbcType.Date, SQL_C_TYPE.TYPE_DATE, SQL_TYPE.TYPE_DATE ));
- OdbcTypeMap.Add (new TypeMap (OdbcType.DateTime, SQL_C_TYPE.TIMESTAMP, SQL_TYPE.TIMESTAMP ));
- OdbcTypeMap.Add (new TypeMap (OdbcType.Decimal, SQL_C_TYPE.NUMERIC, SQL_TYPE.NUMERIC , TypeMap.DefaultAll & (~TypeMap.DefaultForSQLType)));
- OdbcTypeMap.Add (new TypeMap (OdbcType.Double, SQL_C_TYPE.DOUBLE, SQL_TYPE.DOUBLE ));
- OdbcTypeMap.Add (new TypeMap (OdbcType.Image, SQL_C_TYPE.BINARY, SQL_TYPE.BINARY , TypeMap.DefaultAll & (~TypeMap.DefaultForSQLType)));
- OdbcTypeMap.Add (new TypeMap (OdbcType.Int, SQL_C_TYPE.LONG, SQL_TYPE.INTEGER ));
- OdbcTypeMap.Add (new TypeMap (OdbcType.NChar, SQL_C_TYPE.WCHAR, SQL_TYPE.WCHAR ));
- OdbcTypeMap.Add (new TypeMap (OdbcType.NText, SQL_C_TYPE.WCHAR, SQL_TYPE.WLONGVARCHAR));
- OdbcTypeMap.Add (new TypeMap (OdbcType.Numeric, SQL_C_TYPE.NUMERIC, SQL_TYPE.NUMERIC ));
- OdbcTypeMap.Add (new TypeMap (OdbcType.NVarChar, SQL_C_TYPE.WCHAR, SQL_TYPE.WVARCHAR ));
- OdbcTypeMap.Add (new TypeMap (OdbcType.Real, SQL_C_TYPE.FLOAT, SQL_TYPE.REAL ));
- OdbcTypeMap.Add (new TypeMap (OdbcType.SmallDateTime, SQL_C_TYPE.TIMESTAMP, SQL_TYPE.TIMESTAMP , TypeMap.DefaultAll & (~TypeMap.DefaultForSQLType)));
- OdbcTypeMap.Add (new TypeMap (OdbcType.SmallInt, SQL_C_TYPE.SHORT, SQL_TYPE.SMALLINT ));
- OdbcTypeMap.Add (new TypeMap (OdbcType.Text, SQL_C_TYPE.WCHAR, SQL_TYPE.LONGVARCHAR));
- OdbcTypeMap.Add (new TypeMap (OdbcType.Time, SQL_C_TYPE.TYPE_TIME, SQL_TYPE.TYPE_TIME ));
- OdbcTypeMap.Add (new TypeMap (OdbcType.Timestamp, SQL_C_TYPE.BINARY, SQL_TYPE.BINARY , TypeMap.DefaultAll & (~TypeMap.DefaultForSQLType)));
- OdbcTypeMap.Add (new TypeMap (OdbcType.TinyInt, SQL_C_TYPE.UTINYINT, SQL_TYPE.TINYINT ));
- OdbcTypeMap.Add (new TypeMap (OdbcType.UniqueIdentifier,SQL_C_TYPE.GUID, SQL_TYPE.GUID ));
- OdbcTypeMap.Add (new TypeMap (OdbcType.VarBinary, SQL_C_TYPE.BINARY, SQL_TYPE.VARBINARY ));
- OdbcTypeMap.Add (new TypeMap (OdbcType.VarChar, SQL_C_TYPE.WCHAR, SQL_TYPE.WVARCHAR , TypeMap.DefaultAll & (~TypeMap.DefaultForSQLType)));
- }
-
- }
+ OdbcTypeMap = new MapCollection ();
+ OdbcTypeMap.Add (new TypeMap (OdbcType.BigInt, SQL_C_TYPE.SBIGINT, SQL_TYPE.BIGINT ));
+ OdbcTypeMap.Add (new TypeMap (OdbcType.Binary, SQL_C_TYPE.BINARY, SQL_TYPE.BINARY ));
+ OdbcTypeMap.Add (new TypeMap (OdbcType.Bit, SQL_C_TYPE.BIT, SQL_TYPE.BIT ));
+ OdbcTypeMap.Add (new TypeMap (OdbcType.Char, SQL_C_TYPE.CHAR, SQL_TYPE.CHAR ));
+ OdbcTypeMap.Add (new TypeMap (OdbcType.Date, SQL_C_TYPE.TYPE_DATE, SQL_TYPE.TYPE_DATE ));
+ OdbcTypeMap.Add (new TypeMap (OdbcType.DateTime, SQL_C_TYPE.TIMESTAMP, SQL_TYPE.TIMESTAMP ));
+ OdbcTypeMap.Add (new TypeMap (OdbcType.Decimal, SQL_C_TYPE.NUMERIC, SQL_TYPE.NUMERIC , TypeMap.DefaultAll & (~TypeMap.DefaultForSQLType)));
+ OdbcTypeMap.Add (new TypeMap (OdbcType.Double, SQL_C_TYPE.DOUBLE, SQL_TYPE.DOUBLE ));
+ OdbcTypeMap.Add (new TypeMap (OdbcType.Image, SQL_C_TYPE.BINARY, SQL_TYPE.BINARY , TypeMap.DefaultAll & (~TypeMap.DefaultForSQLType)));
+ OdbcTypeMap.Add (new TypeMap (OdbcType.Int, SQL_C_TYPE.LONG, SQL_TYPE.INTEGER ));
+ OdbcTypeMap.Add (new TypeMap (OdbcType.NChar, SQL_C_TYPE.WCHAR, SQL_TYPE.WCHAR ));
+ OdbcTypeMap.Add (new TypeMap (OdbcType.NText, SQL_C_TYPE.WCHAR, SQL_TYPE.WLONGVARCHAR));
+ OdbcTypeMap.Add (new TypeMap (OdbcType.Numeric, SQL_C_TYPE.NUMERIC, SQL_TYPE.NUMERIC ));
+ OdbcTypeMap.Add (new TypeMap (OdbcType.NVarChar, SQL_C_TYPE.WCHAR, SQL_TYPE.WVARCHAR ));
+ OdbcTypeMap.Add (new TypeMap (OdbcType.Real, SQL_C_TYPE.FLOAT, SQL_TYPE.REAL ));
+ OdbcTypeMap.Add (new TypeMap (OdbcType.SmallDateTime, SQL_C_TYPE.TIMESTAMP, SQL_TYPE.TIMESTAMP , TypeMap.DefaultAll & (~TypeMap.DefaultForSQLType)));
+ OdbcTypeMap.Add (new TypeMap (OdbcType.SmallInt, SQL_C_TYPE.SHORT, SQL_TYPE.SMALLINT ));
+ OdbcTypeMap.Add (new TypeMap (OdbcType.Text, SQL_C_TYPE.WCHAR, SQL_TYPE.LONGVARCHAR));
+ OdbcTypeMap.Add (new TypeMap (OdbcType.Time, SQL_C_TYPE.TYPE_TIME, SQL_TYPE.TYPE_TIME ));
+ OdbcTypeMap.Add (new TypeMap (OdbcType.Timestamp, SQL_C_TYPE.BINARY, SQL_TYPE.BINARY , TypeMap.DefaultAll & (~TypeMap.DefaultForSQLType)));
+ OdbcTypeMap.Add (new TypeMap (OdbcType.TinyInt, SQL_C_TYPE.UTINYINT, SQL_TYPE.TINYINT ));
+ OdbcTypeMap.Add (new TypeMap (OdbcType.UniqueIdentifier,SQL_C_TYPE.GUID, SQL_TYPE.GUID ));
+ OdbcTypeMap.Add (new TypeMap (OdbcType.VarBinary, SQL_C_TYPE.BINARY, SQL_TYPE.VARBINARY ));
+ OdbcTypeMap.Add (new TypeMap (OdbcType.VarChar, SQL_C_TYPE.WCHAR, SQL_TYPE.WVARCHAR , TypeMap.DefaultAll & (~TypeMap.DefaultForSQLType)));
}
public static SQL_C_TYPE ConvertToSqlCType (OdbcType type)
diff --git a/mcs/class/System.Data/System.Data.SqlClient/SqlConnectionFactory.cs b/mcs/class/System.Data/System.Data.SqlClient/SqlConnectionFactory.cs
index 626fe1ca4b2..0ec66e6b634 100644
--- a/mcs/class/System.Data/System.Data.SqlClient/SqlConnectionFactory.cs
+++ b/mcs/class/System.Data/System.Data.SqlClient/SqlConnectionFactory.cs
@@ -39,6 +39,7 @@ namespace System.Data.SqlClient {
#region Fields
internal static SqlConnectionFactory Instance; // singleton
private static DbProviderFactory _providerFactory;
+ static readonly object lockobj = new object ();
#endregion // Fields
#region Constructors
@@ -58,17 +59,15 @@ namespace System.Data.SqlClient {
#region Methods
- // create singleton connection factory.
- internal static DbConnectionFactory GetSingleton (DbProviderFactory pvdrFactory)
- {
- lock (typeof (SqlConnectionFactory))
- {
- if (Instance == null)
- Instance = new SqlConnectionFactory (pvdrFactory);
- return Instance;
- }
- }
-
+ // create singleton connection factory.
+ internal static DbConnectionFactory GetSingleton (DbProviderFactory pvdrFactory)
+ {
+ lock (lockobj) {
+ if (Instance == null)
+ Instance = new SqlConnectionFactory (pvdrFactory);
+ return Instance;
+ }
+ }
[MonoTODO]
diff --git a/mcs/class/System.Web/System.Web.Configuration/WebConfigurationSettings.cs b/mcs/class/System.Web/System.Web.Configuration/WebConfigurationSettings.cs
index a7fe0060fb7..3bb18e13379 100644
--- a/mcs/class/System.Web/System.Web.Configuration/WebConfigurationSettings.cs
+++ b/mcs/class/System.Web/System.Web.Configuration/WebConfigurationSettings.cs
@@ -45,14 +45,15 @@ namespace System.Web.Configuration
static WebDefaultConfig config;
static string machineConfigPath;
const BindingFlags privStatic = BindingFlags.NonPublic | BindingFlags.Static;
-
+ static readonly object lockobj = new object ();
+
private WebConfigurationSettings ()
{
}
public static void Init ()
{
- lock (typeof (WebConfigurationSettings)) {
+ lock (lockobj) {
if (config != null)
return;
@@ -88,7 +89,7 @@ namespace System.Web.Configuration
public static string MachineConfigPath {
get {
- lock (typeof (WebConfigurationSettings)) {
+ lock (lockobj) {
if (machineConfigPath != null)
return machineConfigPath;
diff --git a/mcs/class/System.Web/System.Web.Configuration/WebControlsSectionHandler.cs b/mcs/class/System.Web/System.Web.Configuration/WebControlsSectionHandler.cs
index 33fb18a6d7e..99a0f536a52 100644
--- a/mcs/class/System.Web/System.Web.Configuration/WebControlsSectionHandler.cs
+++ b/mcs/class/System.Web/System.Web.Configuration/WebControlsSectionHandler.cs
@@ -38,9 +38,10 @@ namespace System.Web.Configuration
{
class WebControlsConfig
{
- static WebControlsConfig instance;
+ volatile static WebControlsConfig instance;
string scriptsVDir;
string configFilePath;
+ static readonly object lockobj = new object ();
public WebControlsConfig (WebControlsConfig parent, object context)
{
@@ -87,7 +88,7 @@ namespace System.Web.Configuration
if (instance != null)
return instance;
- lock (typeof (WebControlsConfig)) {
+ lock (lockobj) {
if (instance != null)
return instance;
diff --git a/mcs/class/System.Web/System.Web/CapabilitiesLoader.cs b/mcs/class/System.Web/System.Web/CapabilitiesLoader.cs
index 23c8ec8a37d..ac6441614f1 100644
--- a/mcs/class/System.Web/System.Web/CapabilitiesLoader.cs
+++ b/mcs/class/System.Web/System.Web/CapabilitiesLoader.cs
@@ -143,11 +143,19 @@ namespace System.Web
class CapabilitiesLoader : MarshalByRefObject
{
- static bool loaded;
+ static volatile bool loaded;
static ICollection alldata;
static Hashtable defaultCaps;
+ static readonly object lockobj = new object ();
private CapabilitiesLoader () {}
+ static CapabilitiesLoader ()
+ {
+ defaultCaps = new Hashtable ();
+ defaultCaps.Add ("frames", "True");
+ defaultCaps.Add ("tables", "True");
+ }
+
public static Hashtable GetCapabilities (string userAgent)
{
Init ();
@@ -155,15 +163,14 @@ namespace System.Web
userAgent = userAgent.Trim ();
if (alldata == null || userAgent == null || userAgent == "")
- return DefaultCapabilities;
+ return defaultCaps;
foreach (BrowserData bd in alldata) {
- if (bd.IsMatch (userAgent)) {
+ if (bd.IsMatch (userAgent))
return bd.GetProperties (new Hashtable ());
- }
}
- return DefaultCapabilities;
+ return defaultCaps;
}
static void Init ()
@@ -171,7 +178,7 @@ namespace System.Web
if (loaded)
return;
- lock (typeof (CapabilitiesLoader)) {
+ lock (lockobj) {
if (loaded)
return;
@@ -240,20 +247,6 @@ namespace System.Web
data.Add (keyvalue [0], keyvalue [1]);
}
}
-
- static Hashtable DefaultCapabilities {
- get {
- lock (typeof (CapabilitiesLoader)) {
- if (defaultCaps != null)
- return defaultCaps;
-
- defaultCaps = new Hashtable ();
- defaultCaps.Add ("frames", "True");
- defaultCaps.Add ("tables", "True");
- return defaultCaps;
- }
- }
- }
}
}