diff --git a/src/Microsoft.AspNet.Server.Kestrel/Http/Connection.cs b/src/Microsoft.AspNet.Server.Kestrel/Http/Connection.cs
index a6fd1b40bb..d43a1ab4ce 100644
--- a/src/Microsoft.AspNet.Server.Kestrel/Http/Connection.cs
+++ b/src/Microsoft.AspNet.Server.Kestrel/Http/Connection.cs
@@ -24,7 +24,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
private readonly UvStreamHandle _socket;
private Frame _frame;
- long _connectionId;
+ long _connectionId = 0;
public Connection(ListenerContext context, UvStreamHandle socket) : base(context)
{
diff --git a/src/Microsoft.AspNet.Server.Kestrel/Http/SocketOutput.cs b/src/Microsoft.AspNet.Server.Kestrel/Http/SocketOutput.cs
index 02ed046576..4c3e4c8cc8 100644
--- a/src/Microsoft.AspNet.Server.Kestrel/Http/SocketOutput.cs
+++ b/src/Microsoft.AspNet.Server.Kestrel/Http/SocketOutput.cs
@@ -4,7 +4,6 @@
using Microsoft.AspNet.Server.Kestrel.Networking;
using System;
using System.Threading;
-using System.Threading;
namespace Microsoft.AspNet.Server.Kestrel.Http
{
diff --git a/src/Microsoft.AspNet.Server.Kestrel/Networking/Libuv.cs b/src/Microsoft.AspNet.Server.Kestrel/Networking/Libuv.cs
index 4a12712d0d..5429451f2f 100644
--- a/src/Microsoft.AspNet.Server.Kestrel/Networking/Libuv.cs
+++ b/src/Microsoft.AspNet.Server.Kestrel/Networking/Libuv.cs
@@ -58,6 +58,8 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
public int Check(int statusCode)
{
+ var x = Marshal.GetLastWin32Error();
+
Exception error;
var result = Check(statusCode, out error);
if (error != null)
@@ -85,7 +87,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int uv_loop_init(UvLoopHandle a0);
- uv_loop_init _uv_loop_init;
+ uv_loop_init _uv_loop_init = default(uv_loop_init);
public void loop_init(UvLoopHandle handle)
{
Check(_uv_loop_init(handle));
@@ -93,7 +95,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int uv_loop_close(IntPtr a0);
- uv_loop_close _uv_loop_close;
+ uv_loop_close _uv_loop_close = default(uv_loop_close);
public void loop_close(UvLoopHandle handle)
{
handle.Validate(closed: true);
@@ -102,7 +104,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int uv_run(UvLoopHandle handle, int mode);
- uv_run _uv_run;
+ uv_run _uv_run = default(uv_run);
public int run(UvLoopHandle handle, int mode)
{
handle.Validate();
@@ -111,7 +113,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void uv_stop(UvLoopHandle handle);
- uv_stop _uv_stop;
+ uv_stop _uv_stop = default(uv_stop);
public void stop(UvLoopHandle handle)
{
handle.Validate();
@@ -120,7 +122,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void uv_ref(UvHandle handle);
- uv_ref _uv_ref;
+ uv_ref _uv_ref = default(uv_ref);
public void @ref(UvHandle handle)
{
handle.Validate();
@@ -129,7 +131,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void uv_unref(UvHandle handle);
- uv_unref _uv_unref;
+ uv_unref _uv_unref = default(uv_unref);
public void unref(UvHandle handle)
{
handle.Validate();
@@ -141,7 +143,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
public delegate void uv_close_cb(IntPtr handle);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void uv_close(IntPtr handle, uv_close_cb close_cb);
- uv_close _uv_close;
+ uv_close _uv_close = default(uv_close);
public void close(UvHandle handle, uv_close_cb close_cb)
{
handle.Validate(closed: true);
@@ -156,7 +158,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
public delegate void uv_async_cb(IntPtr handle);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int uv_async_init(UvLoopHandle loop, UvAsyncHandle handle, uv_async_cb cb);
- uv_async_init _uv_async_init;
+ uv_async_init _uv_async_init = default(uv_async_init);
public void async_init(UvLoopHandle loop, UvAsyncHandle handle, uv_async_cb cb)
{
loop.Validate();
@@ -166,7 +168,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int uv_async_send(UvAsyncHandle handle);
- uv_async_send _uv_async_send;
+ uv_async_send _uv_async_send = default(uv_async_send);
public void async_send(UvAsyncHandle handle)
{
Check(_uv_async_send(handle));
@@ -174,7 +176,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int uv_tcp_init(UvLoopHandle loop, UvTcpHandle handle);
- uv_tcp_init _uv_tcp_init;
+ uv_tcp_init _uv_tcp_init = default(uv_tcp_init);
public void tcp_init(UvLoopHandle loop, UvTcpHandle handle)
{
loop.Validate();
@@ -184,18 +186,46 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int uv_tcp_bind(UvTcpHandle handle, ref sockaddr addr, int flags);
- uv_tcp_bind _uv_tcp_bind;
+ uv_tcp_bind _uv_tcp_bind = default(uv_tcp_bind);
public void tcp_bind(UvTcpHandle handle, ref sockaddr addr, int flags)
{
handle.Validate();
Check(_uv_tcp_bind(handle, ref addr, flags));
}
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ delegate int uv_tcp_open(UvTcpHandle handle, IntPtr hSocket);
+ uv_tcp_open _uv_tcp_open = default(uv_tcp_open);
+ public void tcp_open(UvTcpHandle handle, IntPtr hSocket)
+ {
+ handle.Validate();
+ Check(_uv_tcp_open(handle, hSocket));
+ }
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ delegate int uv_pipe_init(UvLoopHandle loop, UvPipeHandle handle, int ipc);
+ uv_pipe_init _uv_pipe_init = default(uv_pipe_init);
+ public void pipe_init(UvLoopHandle loop, UvPipeHandle handle, bool ipc)
+ {
+ loop.Validate();
+ handle.Validate();
+ Check(_uv_pipe_init(loop, handle, ipc ? -1 : 0));
+ }
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
+ delegate int uv_pipe_bind(UvPipeHandle loop, string name);
+ uv_pipe_bind _uv_pipe_bind = default(uv_pipe_bind);
+ public void pipe_bind(UvPipeHandle handle, string name)
+ {
+ handle.Validate();
+ Check(_uv_pipe_bind(handle, name));
+ }
+
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void uv_connection_cb(IntPtr server, int status);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int uv_listen(UvStreamHandle handle, int backlog, uv_connection_cb cb);
- uv_listen _uv_listen;
+ uv_listen _uv_listen = default(uv_listen);
public void listen(UvStreamHandle handle, int backlog, uv_connection_cb cb)
{
handle.Validate();
@@ -204,7 +234,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int uv_accept(UvStreamHandle server, UvStreamHandle client);
- uv_accept _uv_accept;
+ uv_accept _uv_accept = default(uv_accept);
public void accept(UvStreamHandle server, UvStreamHandle client)
{
server.Validate();
@@ -212,13 +242,25 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
Check(_uv_accept(server, client));
}
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ public delegate void uv_connect_cb(IntPtr req, int status);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
+ unsafe delegate int uv_pipe_connect(UvConnectRequest req, UvPipeHandle handle, string name, uv_connect_cb cb);
+ uv_pipe_connect _uv_pipe_connect = default(uv_pipe_connect);
+ unsafe public void pipe_connect(UvConnectRequest req, UvPipeHandle handle, string name, uv_connect_cb cb)
+ {
+ req.Validate();
+ handle.Validate();
+ Check(_uv_pipe_connect(req, handle, name, cb));
+ }
+
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void uv_alloc_cb(IntPtr server, int suggested_size, out uv_buf_t buf);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void uv_read_cb(IntPtr server, int nread, ref uv_buf_t buf);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int uv_read_start(UvStreamHandle handle, uv_alloc_cb alloc_cb, uv_read_cb read_cb);
- uv_read_start _uv_read_start;
+ uv_read_start _uv_read_start = default(uv_read_start);
public void read_start(UvStreamHandle handle, uv_alloc_cb alloc_cb, uv_read_cb read_cb)
{
handle.Validate();
@@ -227,7 +269,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int uv_read_stop(UvStreamHandle handle);
- uv_read_stop _uv_read_stop;
+ uv_read_stop _uv_read_stop = default(uv_read_stop);
public void read_stop(UvStreamHandle handle)
{
handle.Validate();
@@ -236,7 +278,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int uv_try_write(UvStreamHandle handle, Libuv.uv_buf_t[] bufs, int nbufs);
- uv_try_write _uv_try_write;
+ uv_try_write _uv_try_write = default(uv_try_write);
public int try_write(UvStreamHandle handle, Libuv.uv_buf_t[] bufs, int nbufs)
{
handle.Validate();
@@ -246,20 +288,30 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void uv_write_cb(IntPtr req, int status);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- unsafe delegate int uv_write(UvWriteReq req, UvStreamHandle handle, Libuv.uv_buf_t* bufs, int nbufs, uv_write_cb cb);
- uv_write _uv_write;
- unsafe public void write(UvWriteReq req, UvStreamHandle handle, Libuv.uv_buf_t* bufs, int nbufs, uv_write_cb cb)
+ unsafe delegate int uv_write(UvRequest req, UvStreamHandle handle, Libuv.uv_buf_t* bufs, int nbufs, uv_write_cb cb);
+ uv_write _uv_write = default(uv_write);
+ unsafe public void write(UvRequest req, UvStreamHandle handle, Libuv.uv_buf_t* bufs, int nbufs, uv_write_cb cb)
{
req.Validate();
handle.Validate();
Check(_uv_write(req, handle, bufs, nbufs, cb));
}
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ unsafe delegate int uv_write2(UvRequest req, UvStreamHandle handle, Libuv.uv_buf_t* bufs, int nbufs, UvStreamHandle sendHandle, uv_write_cb cb);
+ uv_write2 _uv_write2 = default(uv_write2);
+ unsafe public void write2(UvRequest req, UvStreamHandle handle, Libuv.uv_buf_t* bufs, int nbufs, UvStreamHandle sendHandle, uv_write_cb cb)
+ {
+ req.Validate();
+ handle.Validate();
+ Check(_uv_write2(req, handle, bufs, nbufs, sendHandle, cb));
+ }
+
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void uv_shutdown_cb(IntPtr req, int status);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int uv_shutdown(UvShutdownReq req, UvStreamHandle handle, uv_shutdown_cb cb);
- uv_shutdown _uv_shutdown;
+ uv_shutdown _uv_shutdown = default(uv_shutdown);
public void shutdown(UvShutdownReq req, UvStreamHandle handle, uv_shutdown_cb cb)
{
req.Validate();
@@ -269,7 +321,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr uv_err_name(int err);
- uv_err_name _uv_err_name;
+ uv_err_name _uv_err_name = default(uv_err_name);
public unsafe String err_name(int err)
{
IntPtr ptr = _uv_err_name(err);
@@ -278,7 +330,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr uv_strerror(int err);
- uv_strerror _uv_strerror;
+ uv_strerror _uv_strerror = default(uv_strerror);
public unsafe String strerror(int err)
{
IntPtr ptr = _uv_strerror(err);
@@ -287,7 +339,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int uv_loop_size();
- uv_loop_size _uv_loop_size;
+ uv_loop_size _uv_loop_size = default(uv_loop_size);
public int loop_size()
{
return _uv_loop_size();
@@ -295,7 +347,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int uv_handle_size(HandleType handleType);
- uv_handle_size _uv_handle_size;
+ uv_handle_size _uv_handle_size = default(uv_handle_size);
public int handle_size(HandleType handleType)
{
return _uv_handle_size(handleType);
@@ -303,7 +355,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int uv_req_size(RequestType reqType);
- uv_req_size _uv_req_size;
+ uv_req_size _uv_req_size = default(uv_req_size);
public int req_size(RequestType reqType)
{
return _uv_req_size(reqType);
@@ -312,7 +364,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int uv_ip4_addr(string ip, int port, out sockaddr addr);
- uv_ip4_addr _uv_ip4_addr;
+ uv_ip4_addr _uv_ip4_addr = default(uv_ip4_addr);
public int ip4_addr(string ip, int port, out sockaddr addr, out Exception error)
{
return Check(_uv_ip4_addr(ip, port, out addr), out error);
@@ -321,7 +373,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int uv_ip6_addr(string ip, int port, out sockaddr addr);
- uv_ip6_addr _uv_ip6_addr;
+ uv_ip6_addr _uv_ip6_addr = default(uv_ip6_addr);
public int ip6_addr(string ip, int port, out sockaddr addr, out Exception error)
{
return Check(_uv_ip6_addr(ip, port, out addr), out error);
@@ -331,7 +383,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
public delegate void uv_walk_cb(IntPtr handle, IntPtr arg);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
unsafe delegate int uv_walk(UvLoopHandle loop, uv_walk_cb walk_cb, IntPtr arg);
- uv_walk _uv_walk;
+ uv_walk _uv_walk = default(uv_walk);
unsafe public void walk(UvLoopHandle loop, uv_walk_cb walk_cb, IntPtr arg)
{
loop.Validate();
@@ -345,6 +397,8 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
public struct sockaddr
{
+ public sockaddr(long ignored) { x3 = x0 = x1 = x2 = x3 = 0; }
+
long x0;
long x1;
long x2;
diff --git a/src/Microsoft.AspNet.Server.Kestrel/Networking/UvConnectRequest.cs b/src/Microsoft.AspNet.Server.Kestrel/Networking/UvConnectRequest.cs
new file mode 100644
index 0000000000..90791f5fd8
--- /dev/null
+++ b/src/Microsoft.AspNet.Server.Kestrel/Networking/UvConnectRequest.cs
@@ -0,0 +1,70 @@
+// 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.Collections.Generic;
+using System.Diagnostics;
+using System.Runtime.InteropServices;
+
+namespace Microsoft.AspNet.Server.Kestrel.Networking
+{
+ ///
+ /// Summary description for UvWriteRequest
+ ///
+ public class UvConnectRequest : UvRequest
+ {
+ private readonly static Libuv.uv_connect_cb _uv_connect_cb = UvConnectCb;
+
+ Action _callback;
+ object _state;
+
+ public void Init(UvLoopHandle loop)
+ {
+ var requestSize = loop.Libuv.req_size(Libuv.RequestType.CONNECT);
+ CreateMemory(
+ loop.Libuv,
+ loop.ThreadId,
+ requestSize);
+ }
+
+ public void Connect(
+ UvPipeHandle pipe,
+ string name,
+ Action callback,
+ object state)
+ {
+ _callback = callback;
+ _state = state;
+
+ Pin();
+ Libuv.pipe_connect(this, pipe, name, _uv_connect_cb);
+ }
+
+ private static void UvConnectCb(IntPtr ptr, int status)
+ {
+ var req = FromIntPtr(ptr);
+ req.Unpin();
+
+ var callback = req._callback;
+ req._callback = null;
+
+ var state = req._state;
+ req._state = null;
+
+ Exception error = null;
+ if (status < 0)
+ {
+ req.Libuv.Check(status, out error);
+ }
+
+ try
+ {
+ callback(req, status, error, state);
+ }
+ catch (Exception ex)
+ {
+ Trace.WriteLine("UvConnectRequest " + ex.ToString());
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Server.Kestrel/Networking/UvPipeHandle.cs b/src/Microsoft.AspNet.Server.Kestrel/Networking/UvPipeHandle.cs
new file mode 100644
index 0000000000..59e0fbf379
--- /dev/null
+++ b/src/Microsoft.AspNet.Server.Kestrel/Networking/UvPipeHandle.cs
@@ -0,0 +1,40 @@
+// 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;
+
+namespace Microsoft.AspNet.Server.Kestrel.Networking
+{
+ public class UvPipeHandle : UvStreamHandle
+ {
+ public void Init(UvLoopHandle loop, bool ipc)
+ {
+ CreateMemory(
+ loop.Libuv,
+ loop.ThreadId,
+ loop.Libuv.handle_size(Libuv.HandleType.NAMED_PIPE));
+
+ _uv.pipe_init(loop, this, ipc);
+ }
+
+ public void Init(UvLoopHandle loop, Action, IntPtr> queueCloseHandle)
+ {
+ CreateHandle(
+ loop.Libuv,
+ loop.ThreadId,
+ loop.Libuv.handle_size(Libuv.HandleType.TCP), queueCloseHandle);
+
+ _uv.pipe_init(loop, this, false);
+ }
+
+ public void Bind(string name)
+ {
+ _uv.pipe_bind(this, name);
+ }
+
+ //public void Open(IntPtr hSocket)
+ //{
+ //}
+ }
+}
diff --git a/src/Microsoft.AspNet.Server.Kestrel/Networking/UvReq.cs b/src/Microsoft.AspNet.Server.Kestrel/Networking/UvReq.cs
deleted file mode 100644
index 56e738710d..0000000000
--- a/src/Microsoft.AspNet.Server.Kestrel/Networking/UvReq.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-// 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 abstract class UvReq : UvMemory
- {
- protected override bool ReleaseHandle()
- {
- DestroyMemory(handle);
- handle = IntPtr.Zero;
- return true;
- }
- }
-}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Server.Kestrel/Networking/UvRequest.cs b/src/Microsoft.AspNet.Server.Kestrel/Networking/UvRequest.cs
new file mode 100644
index 0000000000..42285e536a
--- /dev/null
+++ b/src/Microsoft.AspNet.Server.Kestrel/Networking/UvRequest.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Threading.Tasks;
+
+namespace Microsoft.AspNet.Server.Kestrel.Networking
+{
+ public class UvRequest : UvMemory
+ {
+ GCHandle _pin;
+
+ protected override bool ReleaseHandle()
+ {
+ DestroyMemory(handle);
+ handle = IntPtr.Zero;
+ return true;
+ }
+
+ public virtual void Pin()
+ {
+ _pin = GCHandle.Alloc(this, GCHandleType.Normal);
+ }
+
+ public virtual void Unpin()
+ {
+ _pin.Free();
+ }
+ }
+}
+
diff --git a/src/Microsoft.AspNet.Server.Kestrel/Networking/UvShutdownReq.cs b/src/Microsoft.AspNet.Server.Kestrel/Networking/UvShutdownReq.cs
index 53073f0e2a..fc40f8967d 100644
--- a/src/Microsoft.AspNet.Server.Kestrel/Networking/UvShutdownReq.cs
+++ b/src/Microsoft.AspNet.Server.Kestrel/Networking/UvShutdownReq.cs
@@ -9,13 +9,12 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
///
/// Summary description for UvShutdownRequest
///
- public class UvShutdownReq : UvReq
+ public class UvShutdownReq : UvRequest
{
private readonly static Libuv.uv_shutdown_cb _uv_shutdown_cb = UvShutdownCb;
Action _callback;
object _state;
- GCHandle _pin;
public void Init(UvLoopHandle loop)
{
@@ -29,14 +28,14 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
{
_callback = callback;
_state = state;
- _pin = GCHandle.Alloc(this, GCHandleType.Normal);
+ Pin();
_uv.shutdown(this, handle, _uv_shutdown_cb);
}
private static void UvShutdownCb(IntPtr ptr, int status)
{
var req = FromIntPtr(ptr);
- req._pin.Free();
+ req.Unpin();
req._callback(req, status, req._state);
req._callback = null;
req._state = null;
diff --git a/src/Microsoft.AspNet.Server.Kestrel/Networking/UvTcpHandle.cs b/src/Microsoft.AspNet.Server.Kestrel/Networking/UvTcpHandle.cs
index 39d2a8a435..281f29190b 100644
--- a/src/Microsoft.AspNet.Server.Kestrel/Networking/UvTcpHandle.cs
+++ b/src/Microsoft.AspNet.Server.Kestrel/Networking/UvTcpHandle.cs
@@ -48,5 +48,10 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
_uv.tcp_bind(this, ref addr, 0);
}
+
+ public void Open(IntPtr hSocket)
+ {
+ _uv.tcp_open(this, hSocket);
+ }
}
}
diff --git a/src/Microsoft.AspNet.Server.Kestrel/Networking/UvWriteReq.cs b/src/Microsoft.AspNet.Server.Kestrel/Networking/UvWriteReq.cs
index 6539d5574f..a97175b7c3 100644
--- a/src/Microsoft.AspNet.Server.Kestrel/Networking/UvWriteReq.cs
+++ b/src/Microsoft.AspNet.Server.Kestrel/Networking/UvWriteReq.cs
@@ -11,7 +11,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
///
/// Summary description for UvWriteRequest
///
- public class UvWriteReq : UvReq
+ public class UvWriteReq : UvRequest
{
private readonly static Libuv.uv_write_cb _uv_write_cb = UvWriteCb;
@@ -26,7 +26,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
public void Init(UvLoopHandle loop)
{
var requestSize = loop.Libuv.req_size(Libuv.RequestType.WRITE);
- var bufferSize = Marshal.SizeOf(typeof(Libuv.uv_buf_t)) * BUFFER_COUNT;
+ var bufferSize = Marshal.SizeOf() * BUFFER_COUNT;
CreateMemory(
loop.Libuv,
loop.ThreadId,
diff --git a/src/Microsoft.AspNet.Server.Kestrel/native/windows/amd64/libuv.dll b/src/Microsoft.AspNet.Server.Kestrel/native/windows/amd64/libuv.dll
index 1174ae2c27..60923dcdb9 100644
Binary files a/src/Microsoft.AspNet.Server.Kestrel/native/windows/amd64/libuv.dll and b/src/Microsoft.AspNet.Server.Kestrel/native/windows/amd64/libuv.dll differ
diff --git a/src/Microsoft.AspNet.Server.Kestrel/native/windows/x86/libuv.dll b/src/Microsoft.AspNet.Server.Kestrel/native/windows/x86/libuv.dll
index 10b4097e6e..0038029c80 100644
Binary files a/src/Microsoft.AspNet.Server.Kestrel/native/windows/x86/libuv.dll and b/src/Microsoft.AspNet.Server.Kestrel/native/windows/x86/libuv.dll differ
diff --git a/test/Microsoft.AspNet.Server.KestrelTests/project.json b/test/Microsoft.AspNet.Server.KestrelTests/project.json
index ea63991f94..afb7e9ad47 100644
--- a/test/Microsoft.AspNet.Server.KestrelTests/project.json
+++ b/test/Microsoft.AspNet.Server.KestrelTests/project.json
@@ -14,6 +14,9 @@
}
}
},
+ "compilationOptions": {
+ "allowUnsafe": true
+ },
"commands": {
"run": "xunit.runner.aspnet",
"test": "xunit.runner.aspnet"