Skip to content
Snippets Groups Projects
Commit 6d53a5c6 authored by Jan Tattermusch's avatar Jan Tattermusch
Browse files

allow specifying channel options when creating a server

parent c8f7d107
No related branches found
No related tags found
No related merge requests found
...@@ -45,7 +45,7 @@ namespace Grpc.Core.Internal ...@@ -45,7 +45,7 @@ namespace Grpc.Core.Internal
internal sealed class ServerSafeHandle : SafeHandleZeroIsInvalid internal sealed class ServerSafeHandle : SafeHandleZeroIsInvalid
{ {
[DllImport("grpc_csharp_ext.dll")] [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")] [DllImport("grpc_csharp_ext.dll")]
static extern int grpcsharp_server_add_http2_port(ServerSafeHandle server, string addr); static extern int grpcsharp_server_add_http2_port(ServerSafeHandle server, string addr);
...@@ -72,7 +72,7 @@ namespace Grpc.Core.Internal ...@@ -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); return grpcsharp_server_create(cq, args);
} }
......
...@@ -52,9 +52,6 @@ namespace Grpc.Core ...@@ -52,9 +52,6 @@ namespace Grpc.Core
/// </summary> /// </summary>
public const int PickUnusedPort = 0; public const int PickUnusedPort = 0;
//readonly OpCompletionDelegate serverShutdownHandler;
//readonly OpCompletionDelegate newServerRpcHandler;
readonly ServerSafeHandle handle; readonly ServerSafeHandle handle;
readonly object myLock = new object(); readonly object myLock = new object();
...@@ -64,11 +61,16 @@ namespace Grpc.Core ...@@ -64,11 +61,16 @@ namespace Grpc.Core
bool startRequested; bool startRequested;
bool shutdownRequested; 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); using (var channelArgs = ChannelOptions.CreateChannelArgs(options))
//this.newServerRpcHandler = HandleNewServerRpc; {
//this.serverShutdownHandler = HandleServerShutdown; this.handle = ServerSafeHandle.NewServer(GetCompletionQueue(), channelArgs);
}
} }
/// <summary> /// <summary>
...@@ -141,8 +143,6 @@ namespace Grpc.Core ...@@ -141,8 +143,6 @@ namespace Grpc.Core
Preconditions.CheckState(!shutdownRequested); Preconditions.CheckState(!shutdownRequested);
shutdownRequested = true; shutdownRequested = true;
} }
var ctx = BatchContextSafeHandle.Create();
handle.ShutdownAndNotify(HandleServerShutdown); handle.ShutdownAndNotify(HandleServerShutdown);
await shutdownTcs.Task; await shutdownTcs.Task;
handle.Dispose(); handle.Dispose();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment