Guarding against more read_cb cases
This commit is contained in:
parent
9c1cb29cdd
commit
21778f631a
|
|
@ -19,12 +19,6 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "SampleApp", "samples\Sample
|
|||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Kestrel", "src\Kestrel\Kestrel.kproj", "{30B7617E-58EF-4382-B3EA-5B2E718CF1A6}"
|
||||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Mvc.Modules", "..\Entropy\samples\Mvc.Modules\Mvc.Modules.kproj", "{181C52C4-E916-416E-96BA-2B645841807F}"
|
||||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.RequestContainer", "..\Hosting\src\Microsoft.AspNet.RequestContainer\Microsoft.AspNet.RequestContainer.kproj", "{374A5B0C-3E93-4A23-A4A0-EE2AB6DF7814}"
|
||||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Hosting", "..\Hosting\src\Microsoft.AspNet.Hosting\Microsoft.AspNet.Hosting.kproj", "{3944F036-7E75-47E8-AA52-C4B89A64EC3A}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(Performance) = preSolution
|
||||
HasPerformanceSessions = true
|
||||
|
|
@ -50,18 +44,6 @@ Global
|
|||
{30B7617E-58EF-4382-B3EA-5B2E718CF1A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{30B7617E-58EF-4382-B3EA-5B2E718CF1A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{30B7617E-58EF-4382-B3EA-5B2E718CF1A6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{181C52C4-E916-416E-96BA-2B645841807F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{181C52C4-E916-416E-96BA-2B645841807F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{181C52C4-E916-416E-96BA-2B645841807F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{181C52C4-E916-416E-96BA-2B645841807F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{374A5B0C-3E93-4A23-A4A0-EE2AB6DF7814}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{374A5B0C-3E93-4A23-A4A0-EE2AB6DF7814}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{374A5B0C-3E93-4A23-A4A0-EE2AB6DF7814}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{374A5B0C-3E93-4A23-A4A0-EE2AB6DF7814}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{3944F036-7E75-47E8-AA52-C4B89A64EC3A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3944F036-7E75-47E8-AA52-C4B89A64EC3A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3944F036-7E75-47E8-AA52-C4B89A64EC3A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3944F036-7E75-47E8-AA52-C4B89A64EC3A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
|
|||
|
|
@ -76,30 +76,43 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
|||
private Libuv.uv_buf_t OnAlloc(UvStreamHandle handle, int suggestedSize)
|
||||
{
|
||||
return handle.Libuv.buf_init(
|
||||
SocketInput.Pin(2048),
|
||||
SocketInput.Pin(2048),
|
||||
2048);
|
||||
}
|
||||
|
||||
private void OnRead(UvStreamHandle handle, int nread, Exception error)
|
||||
private void OnRead(UvStreamHandle handle, int status, Exception error)
|
||||
{
|
||||
SocketInput.Unpin(nread);
|
||||
SocketInput.Unpin(status);
|
||||
|
||||
if (nread == 0 || error != null)
|
||||
var normalRead = error == null && status > 0;
|
||||
var normalDone = status == 0 || status == -4077 || status == -4095;
|
||||
var errorDone = !(normalDone || normalRead);
|
||||
|
||||
if (normalRead)
|
||||
{
|
||||
KestrelTrace.Log.ConnectionRead(_connectionId, status);
|
||||
}
|
||||
else if (normalDone || errorDone)
|
||||
{
|
||||
SocketInput.RemoteIntakeFin = true;
|
||||
KestrelTrace.Log.ConnectionReadFin(_connectionId);
|
||||
|
||||
if (error != null)
|
||||
SocketInput.RemoteIntakeFin = true;
|
||||
|
||||
if (errorDone && error != null)
|
||||
{
|
||||
Trace.WriteLine("Connection.OnRead " + error.ToString());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
KestrelTrace.Log.ConnectionRead(_connectionId, nread);
|
||||
}
|
||||
|
||||
_frame.Consume();
|
||||
|
||||
try
|
||||
{
|
||||
_frame.Consume();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Trace.WriteLine("Connection._frame.Consume " + ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
void IConnectionControl.Pause()
|
||||
|
|
|
|||
|
|
@ -90,16 +90,24 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
|||
|
||||
Buffer = new ArraySegment<byte>(Buffer.Array, Buffer.Offset, Buffer.Count + count);
|
||||
}
|
||||
|
||||
public IntPtr Pin(int minimumSize)
|
||||
{
|
||||
var segment = Available(minimumSize);
|
||||
_gcHandle = GCHandle.Alloc(segment.Array, GCHandleType.Pinned);
|
||||
return _gcHandle.AddrOfPinnedObject() + segment.Offset;
|
||||
}
|
||||
|
||||
public void Unpin(int count)
|
||||
{
|
||||
_gcHandle.Free();
|
||||
Extend(count);
|
||||
// read_cb may called without an earlier alloc_cb
|
||||
// this does not need to be thread-safe
|
||||
// IsAllocated is checked only because Unpin can be called redundantly
|
||||
if (_gcHandle.IsAllocated)
|
||||
{
|
||||
_gcHandle.Free();
|
||||
Extend(count);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,8 +4,17 @@
|
|||
"Microsoft.Framework.Runtime.Interfaces": "1.0.0-*"
|
||||
},
|
||||
"configurations": {
|
||||
"net45": { },
|
||||
"net45": {
|
||||
"compilationOptions": {
|
||||
"define": [ "TRACE", "NET45" ],
|
||||
"allowUnsafe": true
|
||||
}
|
||||
},
|
||||
"k10": {
|
||||
"compilationOptions": {
|
||||
"define": [ "TRACE", "K10" ],
|
||||
"allowUnsafe": true
|
||||
},
|
||||
"dependencies": {
|
||||
"System.Threading.ThreadPool": "4.0.10.0",
|
||||
"System.Diagnostics.Debug": "4.0.10.0",
|
||||
|
|
|
|||
Loading…
Reference in New Issue