diff options
author | Ben Maurer <benm@mono-cvs.ximian.com> | 2005-05-27 03:06:52 +0400 |
---|---|---|
committer | Ben Maurer <benm@mono-cvs.ximian.com> | 2005-05-27 03:06:52 +0400 |
commit | 2a81dac63f6590d7556a61fc1169a6d3d2a5cb29 (patch) | |
tree | f6f43c912f048fccdc2bca1c18df29fd92ab10c0 /mcs/class/System.Data/System.Data.Odbc | |
parent | 270cf818cff0e56f7e346e5f914cdeb864bcb736 (diff) |
locking fixes
svn path=/trunk/mcs/; revision=45085
Diffstat (limited to 'mcs/class/System.Data/System.Data.Odbc')
3 files changed, 45 insertions, 52 deletions
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) |