Attached. On Fri, Mar 21, 2008 at 4:09 PM, Curt Hagenlocher <[EMAIL PROTECTED]> wrote:
> Nope; got it wrong again. I'll just supply a patch once I get this > working. > > > On Fri, Mar 21, 2008 at 2:36 PM, Curt Hagenlocher <[EMAIL PROTECTED]> > wrote: > > > I noticed that this still isn't fixed in 2.0b1, so I took another look > > at socket.cs and realized that my analysis was slightly off. There's > > already a mechanism to track duplicated sockets in the form of the > > handleToSocket mapping. However, this mechanism isn't taken into account > > when deciding whether or not to Close() the BCL Socket object. > > > > Bottom line: I believe this bug can be fixed simply by moving the call > > to _socket.Close() from socket.close into > > socket.RemoveHandleSocketMapping, and only calling it when > > sockets.Countreaches zero. > > On Mon, Feb 18, 2008 at 9:19 PM, Dino Viehland < > > [EMAIL PROTECTED]> wrote: > > > > > This is a great analysis - based upon this I think it'll be pretty > > > easy to fix this. I'll take a look at it tomorrow and respond back. > > > > > > -----Original Message----- > > > From: [EMAIL PROTECTED] [mailto: > > > [EMAIL PROTECTED] On Behalf Of Curt Hagenlocher > > > Sent: Monday, February 18, 2008 4:19 PM > > > To: Discussion of IronPython > > > Subject: Re: [IronPython] urllib.urlretrieve with IronPython 2a8 > > > > > > On Feb 18, 2008 4:12 PM, Curt Hagenlocher <[EMAIL PROTECTED]> > > > wrote: > > > > > > > > Is it possible that CPython's socket.close method won't actually > > > close > > > > the socket while there's still a makefile'd file attacked to the > > > > underlying OS socket? And that IronPython's will? Because that's > > > the > > > > only explanation I can come up with. > > > > > > It is and it will. CPython basically dups the socket handle when you > > > call makefile, while IronPython does not. That's the cause of this > > > bug. > > > > > > By the way, the docstring for the IronPython socket class claims that > > > makefile isn't implemented. This is apparently only half-true. :P > > > > > > -- > > > Curt Hagenlocher > > > [EMAIL PROTECTED] > > > _______________________________________________ > > > Users mailing list > > > Users@lists.ironpython.com > > > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > _______________________________________________ > > > Users mailing list > > > Users@lists.ironpython.com > > > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > > > > > >
--- socket.cs Thu Mar 6 20:22:40 2008 UTC +++ F:\socket.cs Fri Mar 21 23:12:34 2008 UTC @@ -181,15 +181,10 @@ [Documentation("close() -> None\n\nClose the socket. It cannot be used after being closed.")] public void close() { - RemoveHandleSocketMapping(this); - try { - _socket.Close(); - } catch (Exception e) { - throw MakeException(e); - } + RemoveHandleSocketMapping(this, true); } - internal static void RemoveHandleSocketMapping(socket socket) { + internal static void RemoveHandleSocketMapping(socket socket, bool doClose) { lock (handleToSocket) { List<Socket> sockets; if (handleToSocket.TryGetValue((IntPtr)socket._socket.Handle, out sockets)) { @@ -198,6 +193,13 @@ } if (sockets.Count == 0) { handleToSocket.Remove(socket._socket.Handle); + if (doClose) { + try { + socket._socket.Close(); + } catch (Exception e) { + throw MakeException(e); + } + } } } } @@ -669,11 +671,9 @@ if (!handleToSocket.ContainsKey(socket._socket.Handle)) { handleToSocket[socket._socket.Handle] = new List<Socket>(1); } - if (!handleToSocket[socket._socket.Handle].Contains(socket._socket)) { handleToSocket[socket._socket.Handle].Add(socket._socket); } } - } #endregion @@ -1635,7 +1635,7 @@ protected override void Dispose(bool disposing) { socket sock = _userSocket as socket; if (sock != null) { - socket.RemoveHandleSocketMapping(sock); + socket.RemoveHandleSocketMapping(sock, false); } } }
_______________________________________________ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com