[Mono-dev] fix for bug #358987 in 1.9?
Alan McGovern
alan.mcgovern at gmail.com
Thu Feb 21 06:56:35 EST 2008
It may be closed automatically, but *when* will it be closed? There's no
guarantee on when finalizers will be called which is why calling .Close() is
a much better solution (where possible).
Alan.
On Thu, Feb 21, 2008 at 11:53 AM, Zoltan Varga <vargaz at gmail.com> wrote:
> Hi,
>
> I applied the following patch instead to the 1.9 branch:
>
> Index: HttpConnection.cs
> ===================================================================
> --- HttpConnection.cs (revision 96098)
> +++ HttpConnection.cs (working copy)
> @@ -313,8 +313,11 @@
>
> Socket s = sock;
> sock = null;
> - s.Shutdown (SocketShutdown.Both);
> - s.Close ();
> + try {
> + s.Shutdown (SocketShutdown.Both);
> + } finally {
> + s.Close ();
> + }
> if (context_bound)
> epl.UnbindContext (context);
>
> This is still just a workaround, since the socket should be closed
> automatically
> by its finalizer.
>
> Zoltan
>
> On Wed, Feb 20, 2008 at 5:37 PM, Avery Pennarun <apenwarr at gmail.com>
> wrote:
> > 2008/2/20 Steve Bjorg <steveb at mindtouch.com>:
> >
> > > - s.Shutdown (SocketShutdown.Both);
> > > + try {
> > > + s.Shutdown (SocketShutdown.Both);
> > > + } catch(Exception e) {
> > > + // log here?
> > > + }
> > > s.Close ();
> >
> > Why call Shutdown() at all? The shutdown syscall is only useful if
> > you need to keep the fd around longer (eg. if someone else is still
> > holding onto it and you don't want it to be reused). In the above
> > code, close() shuts down the socket anyway.
> >
> > ...unless mono's socket code is doing something different than
> > standard C sockets, that is.
> >
> > Have fun,
> >
> > Avery
> > _______________________________________________
> > 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20080221/ab339a6b/attachment.html
More information about the Mono-devel-list
mailing list