[Mono-bugs] [Bug 73592][Maj] New - socket doesn't close in thread

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Fri, 11 Mar 2005 08:37:08 -0500 (EST)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by borodin@zg.bezopasnost.ru.

http://bugzilla.ximian.com/show_bug.cgi?id=73592

--- shadow/73592	2005-03-11 08:37:08.000000000 -0500
+++ shadow/73592.tmp.28217	2005-03-11 08:37:08.000000000 -0500
@@ -0,0 +1,72 @@
+Bug#: 73592
+Product: Mono: Class Libraries
+Version: 1.1
+OS: GNU/Linux [Other]
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Major
+Component: System
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: borodin@zg.bezopasnost.ru               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: socket doesn't close in thread
+
+If a thread which created a socket and is waiting in EndAccept() is
+aborted, it doesn't close the socket by Close()
+
+mono (and glibc) compiled without NTPL
+
+testcase:
+using System;
+using System.Net;
+using System.Net.Sockets;
+using System.Threading;
+
+class test1 {
+    public test1() {
+
+        Thread t=new Thread(new ThreadStart(thread));
+        t.Start();
+        Console.ReadLine();
+        t.Abort();
+    }
+
+    [MTAThread]
+    static public void Main() {
+        new test1();
+    }
+
+    public void thread() {
+        Socket s=null;
+        IAsyncResult i=null;
+        try {
+            s=new
+Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);
+            IPAddress ipAddress =
+Dns.Resolve(Dns.GetHostName()).AddressList[0];
+            IPEndPoint ipEndpoint = new IPEndPoint(ipAddress, 1800);
+            s.Bind(ipEndpoint);
+            s.Listen(1);
+            Console.Error.WriteLine("listen");
+            i=s.BeginAccept(new AsyncCallback(callback),null);
+            s.EndAccept(i);
+            //s.Accept();
+        } catch (Exception E) {
+            Console.Error.WriteLine(E);
+        } finally {
+            Console.Error.WriteLine("finally");
+            s.Close();
+            Thread.Sleep(5000);
+            Console.Error.WriteLine("finish");
+        }
+    }
+
+    public void callback(IAsyncResult ar) {
+        Console.Error.WriteLine("callback");
+    }
+}