Catch and log uv_accept errors
- This is also what is done by node.js
- "tcp, pipe: don't assert on uv_accept() errors (Ben Noordhuis)"
0685707bc6
This commit is contained in:
parent
f14af1f409
commit
2d01f2752b
|
|
@ -1,11 +1,12 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.AspNet.Server.Kestrel.Infrastructure;
|
||||
using Microsoft.AspNet.Server.Kestrel.Networking;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Server.Kestrel.Infrastructure;
|
||||
using Microsoft.AspNet.Server.Kestrel.Networking;
|
||||
using Microsoft.Framework.Logging;
|
||||
|
||||
namespace Microsoft.AspNet.Server.Kestrel.Http
|
||||
{
|
||||
|
|
@ -56,15 +57,18 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
|||
|
||||
var dispatchPipe = new UvPipeHandle(Log);
|
||||
dispatchPipe.Init(Thread.Loop, true);
|
||||
|
||||
try
|
||||
{
|
||||
pipe.Accept(dispatchPipe);
|
||||
}
|
||||
catch (Exception)
|
||||
catch (UvException ex)
|
||||
{
|
||||
dispatchPipe.Dispose();
|
||||
Log.LogError("ListenerPrimary.OnListenPipe", ex);
|
||||
return;
|
||||
}
|
||||
|
||||
_dispatchPipes.Add(dispatchPipe);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
|||
{
|
||||
DispatchPipe.Accept(acceptSocket);
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (UvException ex)
|
||||
{
|
||||
Log.LogError("DispatchPipe.Accept", ex);
|
||||
acceptSocket.Dispose();
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNet.Server.Kestrel.Infrastructure;
|
||||
using Microsoft.AspNet.Server.Kestrel.Networking;
|
||||
using Microsoft.Framework.Logging;
|
||||
|
||||
namespace Microsoft.AspNet.Server.Kestrel.Http
|
||||
{
|
||||
|
|
@ -36,7 +38,16 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
|||
{
|
||||
var acceptSocket = new UvPipeHandle(Log);
|
||||
acceptSocket.Init(Thread.Loop, false);
|
||||
listenSocket.Accept(acceptSocket);
|
||||
|
||||
try
|
||||
{
|
||||
listenSocket.Accept(acceptSocket);
|
||||
}
|
||||
catch (UvException ex)
|
||||
{
|
||||
Log.LogError("PipeListener.OnConnection", ex);
|
||||
return;
|
||||
}
|
||||
|
||||
DispatchConnection(acceptSocket);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNet.Server.Kestrel.Infrastructure;
|
||||
using Microsoft.AspNet.Server.Kestrel.Networking;
|
||||
using Microsoft.Framework.Logging;
|
||||
|
||||
namespace Microsoft.AspNet.Server.Kestrel.Http
|
||||
{
|
||||
|
|
@ -36,7 +38,16 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
|||
{
|
||||
var acceptSocket = new UvPipeHandle(Log);
|
||||
acceptSocket.Init(Thread.Loop, false);
|
||||
listenSocket.Accept(acceptSocket);
|
||||
|
||||
try
|
||||
{
|
||||
listenSocket.Accept(acceptSocket);
|
||||
}
|
||||
catch (UvException ex)
|
||||
{
|
||||
Log.LogError("ListenerPrimary.OnConnection", ex);
|
||||
return;
|
||||
}
|
||||
|
||||
DispatchConnection(acceptSocket);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Net;
|
||||
using Microsoft.AspNet.Server.Kestrel.Infrastructure;
|
||||
using Microsoft.AspNet.Server.Kestrel.Networking;
|
||||
using Microsoft.Framework.Logging;
|
||||
|
||||
namespace Microsoft.AspNet.Server.Kestrel.Http
|
||||
{
|
||||
|
|
@ -37,7 +39,16 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
|||
{
|
||||
var acceptSocket = new UvTcpHandle(Log);
|
||||
acceptSocket.Init(Thread.Loop, Thread.QueueCloseHandle);
|
||||
listenSocket.Accept(acceptSocket);
|
||||
|
||||
try
|
||||
{
|
||||
listenSocket.Accept(acceptSocket);
|
||||
}
|
||||
catch (UvException ex)
|
||||
{
|
||||
Log.LogError("TcpListener.OnConnection", ex);
|
||||
return;
|
||||
}
|
||||
|
||||
DispatchConnection(acceptSocket);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Net;
|
||||
using Microsoft.AspNet.Server.Kestrel.Infrastructure;
|
||||
using Microsoft.AspNet.Server.Kestrel.Networking;
|
||||
using Microsoft.Framework.Logging;
|
||||
|
||||
namespace Microsoft.AspNet.Server.Kestrel.Http
|
||||
{
|
||||
|
|
@ -37,7 +39,16 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
|||
{
|
||||
var acceptSocket = new UvTcpHandle(Log);
|
||||
acceptSocket.Init(Thread.Loop, Thread.QueueCloseHandle);
|
||||
listenSocket.Accept(acceptSocket);
|
||||
|
||||
try
|
||||
{
|
||||
listenSocket.Accept(acceptSocket);
|
||||
}
|
||||
catch (UvException ex)
|
||||
{
|
||||
Log.LogError("TcpListenerPrimary.OnConnection", ex);
|
||||
return;
|
||||
}
|
||||
|
||||
DispatchConnection(acceptSocket);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
|
|||
{
|
||||
var errorName = err_name(statusCode);
|
||||
var errorDescription = strerror(statusCode);
|
||||
error = new Exception("Error " + statusCode + " " + errorName + " " + errorDescription);
|
||||
error = new UvException("Error " + statusCode + " " + errorName + " " + errorDescription);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.AspNet.Server.Kestrel.Networking
|
||||
{
|
||||
public class UvException : Exception
|
||||
{
|
||||
public UvException(string message) : base(message) { }
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue