Bug 4460 - Socket.Close and Socket.ShutDown block forever
Summary: Socket.Close and Socket.ShutDown block forever
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System ()
Version: 2.10.x
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Martin Baulig
URL:
Depends on:
Blocks:
 
Reported: 2012-04-16 09:22 UTC by Alan McGovern
Modified: 2016-11-11 09:43 UTC (History)
4 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Alan McGovern 2012-04-16 09:22:09 UTC
I have a unit test in git://github.com/mono/monotorrent.git which demonstrates an issue with monos socket handling on MacOS. If you run the 'MonoTorrent.Client.MetadataModeTests.RequestMetadata' test, Mono will hang forever when Socket.Close is called. The sockets are created using the code here:

https://github.com/mono/monotorrent/blob/master/src/MonoTorrent.Tests/Client/TestRig.cs#L295

I have also modified this to set Socket.Linger to 'true' with a timeout of '0' which means that the socket should close immediately and not try to send any pending data, however this has no affect.

I have also tried calling Socket.ShutDown in addition to Socket.Close, but this does not help.

The stacktrace in GDB looks like:

#0  0x9971d2ea in close$UNIX2003 ()
#1  0x001e89b8 in socket_close (handle=0xd, data=0xb0f20b84) at sockets.c:97
#2  0x001d854b in _wapi_handle_unref_full (handle=0xd, ignore_private_busy_handles=0) at handles.c:1194
#3  0x001e8958 in closesocket (fd=13) at sockets.c:187
Comment 1 Martin Baulig 2012-09-18 14:56:43 UTC
This looks very similar to my own personal nightmare, bug #6349 :-(

At least, it's good to know that more people are having this problem.
Comment 2 Martin Baulig 2016-11-11 09:43:31 UTC
Closing ancient bugs, please reopen if you're still having this problem.