[Modify] Polish it

This commit is contained in:
sta 2017-06-05 14:55:23 +09:00
parent 1039994ee8
commit 443fd508b9

View File

@ -753,8 +753,9 @@ namespace WebSocketSharp.Server
private void receiveRequest () private void receiveRequest ()
{ {
while (true) { while (true) {
HttpListenerContext ctx = null;
try { try {
var ctx = _listener.GetContext (); ctx = _listener.GetContext ();
ThreadPool.QueueUserWorkItem ( ThreadPool.QueueUserWorkItem (
state => { state => {
try { try {
@ -766,22 +767,37 @@ namespace WebSocketSharp.Server
processRequest (ctx); processRequest (ctx);
} }
catch (Exception ex) { catch (Exception ex) {
_log.Fatal (ex.ToString ()); _log.Fatal (ex.Message);
_log.Debug (ex.ToString ());
ctx.Connection.Close (true); ctx.Connection.Close (true);
} }
}); }
);
} }
catch (HttpListenerException ex) { catch (HttpListenerException ex) {
_log.Warn ("Receiving has been stopped.\n reason: " + ex.Message); if (_state == ServerState.ShuttingDown) {
_log.Info ("The receiving is stopped.");
break;
}
_log.Fatal (ex.Message);
_log.Debug (ex.ToString ());
break; break;
} }
catch (Exception ex) { catch (Exception ex) {
_log.Fatal (ex.ToString ()); _log.Fatal (ex.Message);
_log.Debug (ex.ToString ());
if (ctx != null)
ctx.Connection.Close (true);
break; break;
} }
} }
if (IsListening) if (_state != ServerState.ShuttingDown)
abort (); abort ();
} }