[Mono-bugs] [Bug 354455] New: Calling SqlConnection. Close on an already closed connection may lead to random errors

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Jan 17 11:08:17 EST 2008


           Summary: Calling SqlConnection.Close on an already closed
                    connection may lead to random errors
           Product: Mono: Class Libraries
           Version: 1.2.6
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Sys.Data.SqlClient
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: jonathan.gagnon at croesus.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---

Created an attachment (id=190873)
 --> (https://bugzilla.novell.com/attachment.cgi?id=190873)
Small test case that doesn't behave properly.  You need to modify the
connection string in order for it to work.

When you call SqlConnection.Close and a connection pool is used, the Close
method puts the underlying tds connection back in the thread pool's list of
available connection.  The problem is that if you call Close repeatedly, the
tds connection is added multiple times in the list which means that more that
one SqlConnection will eventually share the same tds connection.

This situation creates all kind of problems when 2 connections share the same
tds connection and are accessed by concurrent threads.

The easiest solution would be to check if the connection is already closed at
the beginning of the method.  I would also suggest setting the tds variable to
null in the close method to avoid other potential problems (we should not keep
a reference to an object that we have "released").

The same bug affects Mono.Data.SybaseClient.SybaseConnection.

Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.

More information about the mono-bugs mailing list