[Mono-bugs] [Bug 79546][Nor] New - The listener thread is interrupted without any reason

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Sun Oct 1 18:08:05 EDT 2006


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 mono at burnsystems.de.

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

--- shadow/79546	2006-10-01 18:08:05.000000000 -0400
+++ shadow/79546.tmp.8859	2006-10-01 18:08:05.000000000 -0400
@@ -0,0 +1,186 @@
+Bug#: 79546
+Product: Mono: Runtime
+Version: 1.1
+OS: Windows XP
+OS Details: Windows XP SP 2
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: io-layer
+AssignedTo: dick at ximian.com                            
+ReportedBy: mono at burnsystems.de               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: The listener thread is interrupted without any reason
+
+Description of Problem:
+
+The threading of mono seems to be different to the threading of .Net. 
+
+I have following source:
+
+// The server itself
+
+public void ListenerThread()
+{
+    _Listener = new TcpListener(IPAddress.Any, Port);
+    _Listener.Start();
+
+    // Store client und waitlist
+    try
+    {
+	while (_IsRunning)
+	{
+	    TcpClient oClient = _Listener.AcceptTcpClient();
+	    Console.WriteLine(oClient.Client.RemoteEndPoint.ToString());
+
+	    lock (SyncObject)
+	    {
+		_PendingClients.Enqueue(oClient);
+	    }
+
+	    // Check for waiting workerthread
+	    foreach (WorkerThread oWorkerThread in _WorkerThreads)
+	    {
+		if (!oWorkerThread.IsInAction)
+		{
+		    oWorkerThread.IsInAction = true;
+		    oWorkerThread.Event.Set();
+		}
+	    }
+	}
+    }
+    catch (SocketException exc)
+    {
+	Console.WriteLine("MESSAGE:" + exc.Message);
+    }
+}
+
+// The workerthread. The workerthread checks a queue for new
+// tcp connections and returns "HALLO" to the telnet client
+public void ThreadEntry()
+{
+	Console.WriteLine ( "Starting Workerthread" );
+	while ( true )
+	{
+		// Waits for event
+		_Event.WaitOne( TimeSpan.FromSeconds ( 5 ), false );
+
+		if ( !_Server.IsRunning )
+		{
+			break;
+		}
+
+		// In Action
+
+		_IsInAction = true;
+
+		while (true)
+		{
+
+		    // Gets new tcpclient
+		    TcpClient oClient;
+		    lock (_Server.SyncObject)
+		    {
+			if (_Server.PendingClients.Count > 0)
+			{
+			    oClient = _Server.PendingClients.Dequeue();
+			}
+			else
+			{
+			    break;
+			}
+		    }
+
+		    Console.WriteLine("Accepted by Workerthread: " + 
+_WorkerThreadNumber.ToString());
+
+		    try
+		    {
+
+			// Execute this client
+
+			//_Server.Service.AcceptTcpClient(oClient);
+			using (Stream oStream = oClient.GetStream())
+			{
+			    oStream.Write(Encoding.ASCII.GetBytes("HALLO"), 0, 
+5);
+			    Thread.Sleep(10000);
+			    throw new Exception();
+			}
+		    }
+		    catch (Exception exc)
+		    {
+			// Exception has occured
+			Console.WriteLine(exc.Message);
+		    }
+		}
+
+		_IsInAction = false;
+	}
+
+	Console.WriteLine ( "Ending Workerthread" );
+}
+
+I start the server with .Net and mono and connects with telnet to the 
+server. Everything runs fine in mono, except when I close the telnet 
+window and interrupts the connection to the server. The listener thread is 
+interrupted and the server shut downs. I don't see any reason for shutting 
+down the window. It does not happen in .Net.
+
+The binary is compiled by Visual Studio 2005.
+
+The complete source and binary can be downloaded from http://www.depon.net/
+downloads/monoserver.zip
+
+Steps to reproduce the problem:
+1. Execute the server
+2. Connect via telnet 127.0.0.1 1000
+3. Close the telnet windows to interrupt the connection unexpectedly 
+4. Wait for the message 'MESSAGE:interrupted' or repeat the step 2
+
+Actual Results:
+C:\Dokumente und Einstellungen\mbrenn\Eigene Dateien\Visual Studio 
+2005\Projects
+\Webservertest\Webservertest\bin\Release>mono Webservertest.exe
+Arbeitsthreads: 3
+Starting Workerthread
+Starting Workerthread
+Starting Workerthread
+Server is listening
+127.0.0.1:2207
+Accepted by Workerthread: 1
+127.0.0.1:2209
+Accepted by Workerthread: 2
+127.0.0.1:2211
+Accepted by Workerthread: 3
+MESSAGE:interrupted
+Server has stopped listening
+Press key to stop service
+WorkerThread: Exception of type System.Exception was thrown.
+Ending Workerthread
+WorkerThread: Exception of type System.Exception was thrown.
+Ending Workerthread
+WorkerThread: Exception of type System.Exception was thrown.
+Ending Workerthread
+
+Expected Results:
+No interruption of ListenerThread
+
+
+How often does this happen? 
+Everytime
+It also happens when I remove the throwing of the exception
+
+Additional Information:
+Mono JIT compiler version 1.1.17.1, (C) 2002-2006 Novell, Inc and 
+Contributors.
+www.mono-project.com
+        TLS:           normal
+        GC:            Included Boehm (with typed GC)
+        SIGSEGV:       normal
+        Disabled:      none
+unter Windows XP SP 2


More information about the mono-bugs mailing list