diff --git a/src/csharp/Grpc.Core/Internal/GrpcThreadPool.cs b/src/csharp/Grpc.Core/Internal/GrpcThreadPool.cs index 3c94b602c0d..f7f723c00bb 100644 --- a/src/csharp/Grpc.Core/Internal/GrpcThreadPool.cs +++ b/src/csharp/Grpc.Core/Internal/GrpcThreadPool.cs @@ -176,10 +176,10 @@ namespace Grpc.Core.Internal try { var callback = cq.CompletionRegistry.Extract(tag); - // Use cached delegates to avoid unnecessary allocations + queuedContinuationCounter.Increment(); if (!inlineHandlers) { - queuedContinuationCounter.Increment(); + // Use cached delegates to avoid unnecessary allocations ThreadPool.QueueUserWorkItem(success ? runCompletionQueueEventCallbackSuccess : runCompletionQueueEventCallbackFailure, callback); } else diff --git a/src/csharp/Grpc.IntegrationTesting/ClientRunners.cs b/src/csharp/Grpc.IntegrationTesting/ClientRunners.cs index 60696b62d91..48905a27154 100644 --- a/src/csharp/Grpc.IntegrationTesting/ClientRunners.cs +++ b/src/csharp/Grpc.IntegrationTesting/ClientRunners.cs @@ -72,7 +72,7 @@ namespace Grpc.IntegrationTesting Logger.Warning("ClientConfig.CoreList is not supported for C#. Ignoring the value"); } - var channels = CreateChannels(config.ClientChannels, config.ServerTargets, config.SecurityParams); + var channels = CreateChannels(config.ClientChannels, config.ServerTargets, config.SecurityParams, config.ChannelArgs); return new ClientRunnerImpl(channels, config.ClientType, @@ -84,19 +84,20 @@ namespace Grpc.IntegrationTesting () => GetNextProfiler()); } - private static List CreateChannels(int clientChannels, IEnumerable serverTargets, SecurityParams securityParams) + private static List CreateChannels(int clientChannels, IEnumerable serverTargets, SecurityParams securityParams, IEnumerable channelArguments) { GrpcPreconditions.CheckArgument(clientChannels > 0, "clientChannels needs to be at least 1."); GrpcPreconditions.CheckArgument(serverTargets.Count() > 0, "at least one serverTarget needs to be specified."); var credentials = securityParams != null ? TestCredentials.CreateSslCredentials() : ChannelCredentials.Insecure; - List channelOptions = null; + var channelOptions = new List(); if (securityParams != null && securityParams.ServerHostOverride != "") { - channelOptions = new List - { - new ChannelOption(ChannelOptions.SslTargetNameOverride, securityParams.ServerHostOverride) - }; + channelOptions.Add(new ChannelOption(ChannelOptions.SslTargetNameOverride, securityParams.ServerHostOverride)); + } + foreach (var channelArgument in channelArguments) + { + channelOptions.Add(channelArgument.ToChannelOption()); } var result = new List(); diff --git a/src/csharp/Grpc.IntegrationTesting/ControlExtensions.cs b/src/csharp/Grpc.IntegrationTesting/ControlExtensions.cs new file mode 100644 index 00000000000..67f5faed20c --- /dev/null +++ b/src/csharp/Grpc.IntegrationTesting/ControlExtensions.cs @@ -0,0 +1,43 @@ +#region Copyright notice and license + +// Copyright 2016 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#endregion + +using System; +using Grpc.Core; +using Grpc.Testing; + +namespace Grpc.IntegrationTesting +{ + /// + /// Helpers for Control.cs + /// + public static class ControlExtensions + { + public static ChannelOption ToChannelOption(this ChannelArg channelArgument) + { + switch (channelArgument.ValueCase) + { + case ChannelArg.ValueOneofCase.StrValue: + return new ChannelOption(channelArgument.Name, channelArgument.StrValue); + case ChannelArg.ValueOneofCase.IntValue: + return new ChannelOption(channelArgument.Name, channelArgument.IntValue); + default: + throw new ArgumentException("Unsupported channel argument value."); + } + } + } +} diff --git a/src/csharp/Grpc.IntegrationTesting/ServerRunners.cs b/src/csharp/Grpc.IntegrationTesting/ServerRunners.cs index 45bff3aaf8f..e1b47744d50 100644 --- a/src/csharp/Grpc.IntegrationTesting/ServerRunners.cs +++ b/src/csharp/Grpc.IntegrationTesting/ServerRunners.cs @@ -78,7 +78,8 @@ namespace Grpc.IntegrationTesting throw new ArgumentException("Unsupported ServerType"); } - var server = new Server + var channelOptions = new List(config.ChannelArgs.Select((arg) => arg.ToChannelOption())); + var server = new Server(channelOptions) { Services = { service }, Ports = { new ServerPort("[::]", config.Port, credentials) }