https://bugzilla.novell.com/show_bug.cgi?id=642224

https://bugzilla.novell.com/show_bug.cgi?id=642224#c0


           Summary: TcpListener keeps blocking after aborting its owner
                    thread
    Classification: Mono
           Product: Mono: Class Libraries
           Version: SVN
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: System
        AssignedTo: [email protected]
        ReportedBy: [email protected]
         QAContact: [email protected]
          Found By: ---
           Blocker: ---


The following code on .NET exits normally (i.e. aborts the thread and dies
without problem), but on Mono does not exit while both main thread (that called
Thread.Abort) and the aborted thread reach their end points (i.e. they print
"Aborted" and "done." for each).

--------
using System;
using System.Net.Sockets;
using System.Threading;

public class Test
{
    public static void Main ()
    {
        var t = new Thread (new ThreadStart (StartListener));
        t.Start ();
        Thread.Sleep (5000);
        Console.WriteLine ("Aborting...");
        t.Abort ();
        Console.WriteLine ("Aborted");
    }

    static void StartListener ()
    {
#if true
        var l = new TcpListener (9090);
        l.Start ();
        try {
            while (true) {
                var cli = l.EndAcceptTcpClient (l.BeginAcceptTcpClient (null,
null));
                cli.Close ();
            }
        } finally {
            Console.WriteLine ("done.");
        }
#else
        var d = new Action (DoWork);
        try {
            d.EndInvoke (d.BeginInvoke (null, null));
        } finally {
            Console.WriteLine ("done.");
        }
#endif
    }

    static void DoWork ()
    {
        Thread.Sleep (10000);
    }
}

--------

Note that for usual thread activities it works fine e.g. toggling #if switch in
the above code works fine (the program exits).

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
_______________________________________________
mono-bugs maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-bugs

Reply via email to