Bugs item #1513223, was opened at 2006-06-27 09:54
Message generated for change (Comment added) made by splitscreen
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1513223&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Extension Modules
Group: Python 2.5
Status: Open
Resolution: None
Priority: 7
Submitted By: Irmen de Jong (irmen)
Assigned to: Nobody/Anonymous (nobody)
Summary: socket close() hangs client if used without prior shutdown()

Initial Comment:
In Python 2.5b1, when closing a client socket using
socket.close(), the connecting client hangs. I.e. the
socket is not properly taken down. If you add an
explicit call to socket.shutdown(), prior to the
close(), it works again.

But I think this shutdown() should not be mandatory? At
least, it wasn't in older Python versions.

Sample code attached. Run the script and connect to
socket 9000. If you remove the call to shutdown, your
client connection will hang (use telnet or netcat).


----------------------------------------------------------------------

Comment By: Matt Fleming (splitscreen)
Date: 2006-07-01 14:47

Message:
Logged In: YES 
user_id=1126061

The patch fixes the problem for me too, on NetBSD 3.0, 

revision 47189.

Thanks, Matt

----------------------------------------------------------------------

Comment By: Neal Norwitz (nnorwitz)
Date: 2006-07-01 08:22

Message:
Logged In: YES 
user_id=33168

The attached patch fixes the problem for me.  It includes a
test.  If no one gets to it in the next few days, I'll apply it.

It could be augmented with Martin's suggestion to check the
refcount.

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2006-06-30 16:34

Message:
Logged In: YES 
user_id=21627

The problem is that _socketobject.close fails to set
recv_into and recvfrom_into to _dummy.

The real problem seems to me that close relies on 
refcounting to close the underlying socket object. I think 
it should first call self._sock.close() before releasing
it.

Also, a test case should be added that the socket object
really does go away after close, e.g. in the form

 native_socket = s._sock
 s.close()
 assert sys.getrefcount(native_socket) == 2


----------------------------------------------------------------------

Comment By: Neal Norwitz (nnorwitz)
Date: 2006-06-30 06:07

Message:
Logged In: YES 
user_id=33168

Shutdown should not be mandatory.

I can reproduce the same behaviour under linux.  This is new
breakage in 2.5 and needs to be fixed.

----------------------------------------------------------------------

Comment By: Irmen de Jong (irmen)
Date: 2006-06-27 09:55

Message:
Logged In: YES 
user_id=129426

Oops forgot to mention: Tested with Python2.5b1 (official
binary releases) on Windows XP and on Mac OS tiger.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1513223&group_id=5470
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to