[Mono-devel-list] [PATCH] bug-60172 : OdbcConnection not closing properly
T Sureshkumar
tsureshkumar at novell.com
Mon Jun 21 00:59:40 EDT 2004
Hi,
I have attached a patch for bug bugzila-id :60172. The detailed description of the patch is given at the end of this mail.
The patch is for OdbcConnection class ( mcs/class/System.Data/System.Data.Odbc/OdbcConnection.cs ). I have moved the env handle allocation to Open method rather than the constructor, so that we can free them when Close method is called. In the Close method, I have disconnected the Odbc connection using SQLDisconnect & freed the handles env & dbc using SQLFreeHandle.
I have checked the fix against MySql db & mono/MS.NET runtime.
Somebody could verify the patch & please suggest me any problem/enhancement with this patch.
FYI : The second part of the patch is for method "Open". diff does not show the method name in the diff file in this case.. i.e. after the line ---- "@@ -220,11 +228,22 @@"
Best Regards,
Suresh.
BUG DESCRIPTION : 60172
================================================================================
Opened by sebastien.robitaille at croesus.com (Sébastien Robitaille) on 2004-06-14 18:23 Long Description
Description of Problem:
An exception is thrown when OdbcConnection.Open is called more than 188
times.
Hint: OdbcConnection is leaking ODBC resource handles.
The following members in OdbcConnection.cs are allocated with
SQLAllocHandle but are never freed with SQLFreeHandle:
henv, hdbc
Steps to reproduce the problem:
1. Call OdbcConnection.Open() many times and see that after 188 calls, an
exception is thrown:
System.Data.Odbc.OdbcException: [unixODBC][FreeTDS][SQL Server]Login
incorrect.
in <0x003c8> System.Data.Odbc.OdbcConnection:Open ()
in <0x0004f> (wrapper remoting-invoke-with-check)
System.Data.Odbc.OdbcConnection:Open ()
in <0x0006b> MonoOdbcDataSetTest.Class1:TestConnections ()
2. Execute the following code:
OdbcConnection connection = new OdbcConnection(connectionString);
for(int nIndex = 0; nIndex < 1000; nIndex++)
{
connection.Open();
System.Console.WriteLine(nIndex);
connection.Close();
}
Actual Results:
0
1
...
186
187
188
System.Data.Odbc.OdbcException: [unixODBC][FreeTDS][SQL Server]Login
incorrect.
in <0x003c8> System.Data.Odbc.OdbcConnection:Open ()
in <0x0004f> (wrapper remoting-invoke-with-check)
System.Data.Odbc.OdbcConnection:Open ()
in <0x0006b> MonoOdbcDataSetTest.Class1:TestConnections ()
Expected Results:
0
1
...
998
999
How often does this happen?
Always
Additional Information:
Sybase Database
mono-0.95
freetds-0.62.3
unixODBC-2.2.8
------- Additional Comments From Sébastien Robitaille 2004-06-15 15:01 -------
After investigation, the number "188" specified un the Bug
description is related to the maximum number of simultaneous
connections authorized by the database engine (200 on my database).
The Close method doesn't seem to behave correctly (It doesn't
actually close the database connection).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 60172_patch.diff
Type: application/octet-stream
Size: 4768 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20040620/92d6b295/attachment.obj
More information about the Mono-devel-list
mailing list