[Mono-devel-list] Patch for SqlConnection

Rafael Teixeira monoman at gmail.com
Fri Mar 11 13:17:54 EST 2005


Hi Suresh,

A programmer may forget to close a connection before it is collected.
Surely in the server-side there are resouces that should be freed.
That is why SQLConnection DOES have unmanaged resources to free. If
our implementation isn't doing so in the finalizer/dispose it is in
error, period.

HIH,

On Fri, 11 Mar 2005 12:56:05 +0530, Sureshkumar T
<tsureshkumar at novell.com> wrote:
> > From: Gonzalo Paniagua Javier <gonzalo at ximian.com>
> > To: Mono Development <mono-devel-list at lists.ximian.com>
> > Subject: [Mono-devel-list] Patch for SqlConnection
> > Date: Fri, 11 Mar 2005 00:50:59 -0500
> >
> > Hi.
> >
> > Attached there's a small patch that adds a finalizer to SqlConnection
> > and moves the 'disposed = true' into the finally in Dispose(bool).
> 
> SqlConnection does not have any unmanaged resources. Hence, IMHO, it is
> not necessary to have finalizer method. We can avoid an overhead to GC.
> 
> I donot see the reason to mark disposed to true in case any exception
> occurs while closing the connection.
> 
> -suresh.
> 
> >
> > Any objections?
> >
> > -Gonzalo
> >
> >
> > --=-yYoFVNPF2KxporljqjIH
> > Content-Disposition: attachment; filename=patchety.patch
> > Content-Type: text/x-patch; name=patchety.patch; charset=UTF-8
> > Content-Transfer-Encoding: 7bit
> >
> > Index: SqlConnection.cs
> > ===================================================================
> > --- SqlConnection.cs  (revision 41656)
> > +++ SqlConnection.cs  (working copy)
> > @@ -411,11 +411,10 @@
> >                                                  dataSource = ""; // default dataSource
> >                                                  ConnectionString = null;
> >                                          }
> > +                                } finally {
> >                                          disposed = true;
> > -                                } finally {
> >                                          base.Dispose (disposing);
> >                                  }
> > -
> >                       }
> >               }
> >
> > @@ -455,6 +454,11 @@
> >                       GC.SuppressFinalize (this);
> >               }
> >
> > +             ~SqlConnection ()
> > +             {
> > +                     Dispose (false);
> > +             }
> > +
> >               public
> >  #if NET_2_0
> >               override
> >
> > --=-yYoFVNPF2KxporljqjIH--
> >
> > _______________________________________________
> > Mono-devel-list mailing list
> > Mono-devel-list at lists.ximian.com
> > http://lists.ximian.com/mailman/listinfo/mono-devel-list
> 
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
> 


-- 
Rafael "Monoman" Teixeira
---------------------------------------
I'm trying to become a "Rosh Gadol" before my own eyes. 
See http://www.joelonsoftware.com/items/2004/12/06.html for enlightment.



More information about the Mono-devel-list mailing list