[Mono-bugs] [Bug 45381][Blo] New - TcpListener.Pending improperly hangs

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
Tue, 24 Jun 2003 15:16:46 -0400 (EDT)


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 nate@suppleye.com.

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

--- shadow/45381	Tue Jun 24 15:16:46 2003
+++ shadow/45381.tmp.13840	Tue Jun 24 15:16:46 2003
@@ -0,0 +1,119 @@
+Bug#: 45381
+Product: Mono/Class Libraries
+Version: unspecified
+OS: GNU/Linux [Other]
+OS Details: Gentoo Linux.  (2.4.20 kernel)
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Blocker
+Component: System
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: nate@suppleye.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: TcpListener.Pending improperly hangs
+
+Please fill in this template when reporting a bug, unless you know what 
+you are doing.
+Description of Problem:
+
+TcpListener.Pending blocks for 1000 seconds (approximatly 16 minutes) 
+under linux.  This problem does not seem to occur under windows.
+The problem was originally seen under mono 0.23, however I do not believe 
+it is fixed in 0.24.
+
+gentoox@XboX gentoox $ uname -a
+Linux XboX 2.4.20-xbox #1 Wed May 21 12:12:39 BST 2003 i686 Celeron 
+(Coppermine) GenuineIntel GNU/Linux
+gentoox@XboX gentoox $
+
+Note that this install of gentoo has the xbox-linux kernel patches 
+applied, however I have confirmed, both by my own review and from speaking 
+to the developers, that this patch does not affect the network layers.
+
+Steps to reproduce the problem:
+-----Sample.cs-----
+using System;
+using System.Net.Sockets;
+
+
+namespace Test
+{
+
+	public class Sample
+	{
+		public static void Main(String[] args)
+		{
+			//create the bugged listener
+			TcpListener listener = new TcpListener(3000);
+
+			try
+			{
+				//begin listening for connections
+				listener.Start();
+			}
+			catch(Exception e)
+			{
+				//exit if unable to start listening
+				Console.WriteLine("Could not start 
+listener: " + e);
+				return;
+			}
+
+				//display time before call to Pending
+				System.Console.WriteLine("Time before call 
+to Pending: " + DateTime.Now.ToLongTimeString());
+				
+				//call buggy Pending method
+				if(listener.Pending())
+				{
+					//answer any connections that do 
+show up
+					Socket s = listener.AcceptSocket();
+					s.Close();
+				}
+				//display time after call to Pending
+				System.Console.WriteLine("Time After call 
+to Pending: " + DateTime.Now.ToLongTimeString());
+				System.Console.WriteLine("-----");
+		}
+	
+	}
+}
+-----Sample.cs-----
+
+Actual Results:
+gentoox@XboX gentoox $ mcs Sample.c
+Compilation succeeded
+gentoox@XboX gentoox $ mono ./Sample.exe
+Time before call to Pending: 19:45:00
+Time After  call to Pending: 20:01:40
+-----
+gentoox@XboX gentoox $
+
+
+Expected Results:
+This is the output of the same source compiled and run under windows
+
+C:\Documents and Settings\Nate\My Documents\Visual Studio 
+Projects\DashPoc\src>mono .\Sample.exe
+Time before call to Pending: 15:12:30
+Time After call to Pending: 15:12:30
+-----
+
+C:\Documents and Settings\Nate\My Documents\Visual Studio 
+Projects\DashPoc\src>
+
+How often does this happen? 
+  Always!
+
+Additional Information:
+  I believe that the bug is caused by TcpListener.Pending passing a value 
+of 1000 to Socket.Poll, which in turn passes this 1000 to Select_internal, 
+which I am assuming is improperly filling in the timeout structure to be 
+passed to select.  If a connection does come in before or during the 16 
+second call the TcpListener.Pending, the Pending call returns, as it 
+should.