Permalink
Browse files

Fix shutdown problems

	SingleApp mode is not shutting down properly with master (runtime
	problem?). This is a workaround to exit when the final OnAccept is
	called upon listener socket closing.
  • Loading branch information...
1 parent d463279 commit fc71d3e98bef5f25649332a209a68b03c280d3bb @gonzalop gonzalop committed Sep 1, 2011
Showing with 7 additions and 1 deletion.
  1. +7 −1 src/Mono.WebServer/ApplicationServer.cs
@@ -401,6 +401,11 @@ void RunServer ()
void OnAccept (object sender, EventArgs e)
{
+ if (!started && single_app) {
+ // We are shutting down. Last call...
+ Environment.Exit (0);
+ }
+
SocketAsyncEventArgs args = (SocketAsyncEventArgs) e;
Socket accepted = args.AcceptSocket;
args.AcceptSocket = null;
@@ -414,7 +419,8 @@ void OnAccept (object sender, EventArgs e)
if (started)
listen_socket.AcceptAsync (args);
} catch (Exception ex) {
- CloseSocket(accepted);
+ if (accepted != null)
+ CloseSocket (accepted);
// not much we can do. fast fail by killing the process.
Console.Error.WriteLine ("Unable to accept socket. Exiting the process. {0}", ex);

0 comments on commit fc71d3e

Please sign in to comment.