aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Jan Tattermusch <jtattermusch@google.com>2015-06-08 18:03:05 -0700
committerGravatar Jan Tattermusch <jtattermusch@google.com>2015-06-09 16:06:29 -0700
commit6d53a5c60b63f38334140e1e7de9c448a030bc4d (patch)
tree8a2bb503fea6e69bb5a500986c3a3437f064a28a
parentc8f7d1079e66a87e1248462b5ff2216460f488ab (diff)
allow specifying channel options when creating a server
-rw-r--r--src/csharp/Grpc.Core/Internal/ServerSafeHandle.cs4
-rw-r--r--src/csharp/Grpc.Core/Server.cs18
2 files changed, 11 insertions, 11 deletions
diff --git a/src/csharp/Grpc.Core/Internal/ServerSafeHandle.cs b/src/csharp/Grpc.Core/Internal/ServerSafeHandle.cs
index edd9c490ff..9fda1f6569 100644
--- a/src/csharp/Grpc.Core/Internal/ServerSafeHandle.cs
+++ b/src/csharp/Grpc.Core/Internal/ServerSafeHandle.cs
@@ -45,7 +45,7 @@ namespace Grpc.Core.Internal
internal sealed class ServerSafeHandle : SafeHandleZeroIsInvalid
{
[DllImport("grpc_csharp_ext.dll")]
- static extern ServerSafeHandle grpcsharp_server_create(CompletionQueueSafeHandle cq, IntPtr args);
+ static extern ServerSafeHandle grpcsharp_server_create(CompletionQueueSafeHandle cq, ChannelArgsSafeHandle args);
[DllImport("grpc_csharp_ext.dll")]
static extern int grpcsharp_server_add_http2_port(ServerSafeHandle server, string addr);
@@ -72,7 +72,7 @@ namespace Grpc.Core.Internal
{
}
- public static ServerSafeHandle NewServer(CompletionQueueSafeHandle cq, IntPtr args)
+ public static ServerSafeHandle NewServer(CompletionQueueSafeHandle cq, ChannelArgsSafeHandle args)
{
return grpcsharp_server_create(cq, args);
}
diff --git a/src/csharp/Grpc.Core/Server.cs b/src/csharp/Grpc.Core/Server.cs
index da59fc7232..de10be39ab 100644
--- a/src/csharp/Grpc.Core/Server.cs
+++ b/src/csharp/Grpc.Core/Server.cs
@@ -52,9 +52,6 @@ namespace Grpc.Core
/// </summary>
public const int PickUnusedPort = 0;
- //readonly OpCompletionDelegate serverShutdownHandler;
- //readonly OpCompletionDelegate newServerRpcHandler;
-
readonly ServerSafeHandle handle;
readonly object myLock = new object();
@@ -64,11 +61,16 @@ namespace Grpc.Core
bool startRequested;
bool shutdownRequested;
- public Server()
+ /// <summary>
+ /// Create a new server.
+ /// </summary>
+ /// <param name="options">Channel options.</param>
+ public Server(IEnumerable<ChannelOption> options = null)
{
- this.handle = ServerSafeHandle.NewServer(GetCompletionQueue(), IntPtr.Zero);
- //this.newServerRpcHandler = HandleNewServerRpc;
- //this.serverShutdownHandler = HandleServerShutdown;
+ using (var channelArgs = ChannelOptions.CreateChannelArgs(options))
+ {
+ this.handle = ServerSafeHandle.NewServer(GetCompletionQueue(), channelArgs);
+ }
}
/// <summary>
@@ -141,8 +143,6 @@ namespace Grpc.Core
Preconditions.CheckState(!shutdownRequested);
shutdownRequested = true;
}
-
- var ctx = BatchContextSafeHandle.Create();
handle.ShutdownAndNotify(HandleServerShutdown);
await shutdownTcs.Task;
handle.Dispose();