diff --git a/.github/mergeable.yml b/.github/mergeable.yml index f0180b99798..660d8cb4405 100644 --- a/.github/mergeable.yml +++ b/.github/mergeable.yml @@ -2,5 +2,5 @@ mergeable: pull_requests: label: must_include: - regex: "release notes:yes|release notes:no" + regex: "release notes: yes|release notes: no" message: "Add release notes yes/no label. For yes, add lang label" diff --git a/doc/csharp/server_reflection.md b/doc/csharp/server_reflection.md new file mode 100644 index 00000000000..97216802694 --- /dev/null +++ b/doc/csharp/server_reflection.md @@ -0,0 +1,53 @@ +# gRPC C# Server Reflection + +This document shows how to use gRPC Server Reflection in gRPC C#. +Please see [C++ Server Reflection Tutorial](../server_reflection_tutorial.md) +for general information and more examples how to use server reflection. + +## Enable server reflection in C# servers + +C# Server Reflection is an add-on library. +To use it, first install the [Grpc.Reflection](https://www.nuget.org/packages/Grpc.Reflection/) +Nuget package into your project. + +Note that with C# you need to manually register the service +descriptors with the reflection service implementation when creating a server +(this isn't necessary with e.g. C++ or Java) +```csharp +// the reflection service will be aware of "Greeter" and "ServerReflection" services. +var reflectionServiceImpl = new ReflectionServiceImpl(Greeter.Descriptor, ServerReflection.Descriptor); +server = new Server() +{ + Services = + { + // the server will serve 2 services, the Greeter and the ServerReflection + ServerReflection.BindService(new GreeterImpl()), + ServerReflection.BindService(reflectionServiceImpl) + }, + Ports = { { "localhost", 50051, ServerCredentials.Insecure } } +}; +server.Start(); +``` + +After starting the server, you can verify that the server reflection +is working properly by using the `grpc_cli` command line tool: + + ```sh + $ grpc_cli ls localhost:50051 + ``` + + output: + ```sh + helloworld.Greeter + grpc.reflection.v1alpha.ServerReflection + ``` + + For more examples and instructions how to use the `grpc_cli` tool, + please refer to the [`grpc_cli` documentation](../command_line_tool.md) + and the [C++ Server Reflection Tutorial](../server_reflection_tutorial.md). + +## Additional Resources + +The [Server Reflection Protocol](../server-reflection.md) provides detailed +information about how the server reflection works and describes the server reflection +protocol in detail. diff --git a/doc/server_reflection_tutorial.md b/doc/server_reflection_tutorial.md index ecb176723cc..06a257c1e87 100644 --- a/doc/server_reflection_tutorial.md +++ b/doc/server_reflection_tutorial.md @@ -10,7 +10,7 @@ RPCs. ### Enable server reflection in C++ servers -C++ Server Reflection is an add-on library, `libgrpc++_reflction`. To enable C++ +C++ Server Reflection is an add-on library, `libgrpc++_reflection`. To enable C++ server reflection, you can link this library to your server binary. Some platforms (e.g. Ubuntu 11.10 onwards) only link in libraries that directly diff --git a/examples/csharp/helloworld-from-cli/Greeter.sln b/examples/csharp/Helloworld/Greeter.sln similarity index 100% rename from examples/csharp/helloworld-from-cli/Greeter.sln rename to examples/csharp/Helloworld/Greeter.sln diff --git a/examples/csharp/helloworld-from-cli/Greeter/Greeter.csproj b/examples/csharp/Helloworld/Greeter/Greeter.csproj similarity index 79% rename from examples/csharp/helloworld-from-cli/Greeter/Greeter.csproj rename to examples/csharp/Helloworld/Greeter/Greeter.csproj index 3bff4a576bb..3d4be5da6b4 100644 --- a/examples/csharp/helloworld-from-cli/Greeter/Greeter.csproj +++ b/examples/csharp/Helloworld/Greeter/Greeter.csproj @@ -11,8 +11,8 @@ - - + + diff --git a/examples/csharp/helloworld-from-cli/Greeter/Helloworld.cs b/examples/csharp/Helloworld/Greeter/Helloworld.cs similarity index 100% rename from examples/csharp/helloworld-from-cli/Greeter/Helloworld.cs rename to examples/csharp/Helloworld/Greeter/Helloworld.cs diff --git a/examples/csharp/helloworld-from-cli/Greeter/HelloworldGrpc.cs b/examples/csharp/Helloworld/Greeter/HelloworldGrpc.cs similarity index 100% rename from examples/csharp/helloworld-from-cli/Greeter/HelloworldGrpc.cs rename to examples/csharp/Helloworld/Greeter/HelloworldGrpc.cs diff --git a/examples/csharp/helloworld-from-cli/GreeterClient/GreeterClient.csproj b/examples/csharp/Helloworld/GreeterClient/GreeterClient.csproj similarity index 100% rename from examples/csharp/helloworld-from-cli/GreeterClient/GreeterClient.csproj rename to examples/csharp/Helloworld/GreeterClient/GreeterClient.csproj diff --git a/examples/csharp/helloworld-from-cli/GreeterClient/Program.cs b/examples/csharp/Helloworld/GreeterClient/Program.cs similarity index 100% rename from examples/csharp/helloworld-from-cli/GreeterClient/Program.cs rename to examples/csharp/Helloworld/GreeterClient/Program.cs diff --git a/examples/csharp/helloworld-from-cli/GreeterServer/GreeterServer.csproj b/examples/csharp/Helloworld/GreeterServer/GreeterServer.csproj similarity index 100% rename from examples/csharp/helloworld-from-cli/GreeterServer/GreeterServer.csproj rename to examples/csharp/Helloworld/GreeterServer/GreeterServer.csproj diff --git a/examples/csharp/helloworld-from-cli/GreeterServer/Program.cs b/examples/csharp/Helloworld/GreeterServer/Program.cs similarity index 100% rename from examples/csharp/helloworld-from-cli/GreeterServer/Program.cs rename to examples/csharp/Helloworld/GreeterServer/Program.cs diff --git a/examples/csharp/helloworld-from-cli/README.md b/examples/csharp/Helloworld/README.md similarity index 73% rename from examples/csharp/helloworld-from-cli/README.md rename to examples/csharp/Helloworld/README.md index b780fa1b2fd..e6031794388 100644 --- a/examples/csharp/helloworld-from-cli/README.md +++ b/examples/csharp/Helloworld/README.md @@ -3,9 +3,6 @@ gRPC in 3 minutes (C#) BACKGROUND ------------- -This is a different version of the helloworld example, using the dotnet sdk -tools to build and run. - For this sample, we've already generated the server and client stubs from [helloworld.proto][]. Example projects in this directory depend on the [Grpc](https://www.nuget.org/packages/Grpc/) @@ -15,17 +12,19 @@ which have been already added to the project for you. PREREQUISITES ------------- -- The [.NET Core SDK](https://www.microsoft.com/net/core). +- The [.NET Core SDK](https://www.microsoft.com/net/core) (version 2+ is recommended) + +You can also build the example directly using Visual Studio 2017, but it's not a requirement. BUILD ------- -From the `examples/csharp/helloworld-from-cli` directory: - -- `dotnet restore Greeter.sln` +From the `examples/csharp/Helloworld` directory: - `dotnet build Greeter.sln` +(if you're using dotnet SDK 1.x you need to run `dotnet restore Greeter.sln` first) + Try it! ------- diff --git a/examples/csharp/helloworld-from-cli/generate_protos.bat b/examples/csharp/Helloworld/generate_protos.bat similarity index 100% rename from examples/csharp/helloworld-from-cli/generate_protos.bat rename to examples/csharp/Helloworld/generate_protos.bat diff --git a/examples/csharp/helloworld/Greeter.sln b/examples/csharp/HelloworldLegacyCsproj/Greeter.sln similarity index 100% rename from examples/csharp/helloworld/Greeter.sln rename to examples/csharp/HelloworldLegacyCsproj/Greeter.sln diff --git a/examples/csharp/helloworld/Greeter/.gitignore b/examples/csharp/HelloworldLegacyCsproj/Greeter/.gitignore similarity index 100% rename from examples/csharp/helloworld/Greeter/.gitignore rename to examples/csharp/HelloworldLegacyCsproj/Greeter/.gitignore diff --git a/examples/csharp/helloworld/Greeter/Greeter.csproj b/examples/csharp/HelloworldLegacyCsproj/Greeter/Greeter.csproj similarity index 72% rename from examples/csharp/helloworld/Greeter/Greeter.csproj rename to examples/csharp/HelloworldLegacyCsproj/Greeter/Greeter.csproj index d2597f13b5f..ab584c86d3e 100644 --- a/examples/csharp/helloworld/Greeter/Greeter.csproj +++ b/examples/csharp/HelloworldLegacyCsproj/Greeter/Greeter.csproj @@ -36,15 +36,15 @@ ..\packages\Google.Protobuf.3.5.0\lib\net45\Google.Protobuf.dll True - - ..\packages\Grpc.Core.1.8.0\lib\net45\Grpc.Core.dll - True - ..\packages\System.Interactive.Async.3.1.1\lib\net45\System.Interactive.Async.dll True + + ..\packages\Grpc.Core.1.13.1\lib\net45\Grpc.Core.dll + + @@ -62,11 +62,5 @@ - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - + \ No newline at end of file diff --git a/examples/csharp/helloworld/Greeter/Helloworld.cs b/examples/csharp/HelloworldLegacyCsproj/Greeter/Helloworld.cs similarity index 100% rename from examples/csharp/helloworld/Greeter/Helloworld.cs rename to examples/csharp/HelloworldLegacyCsproj/Greeter/Helloworld.cs diff --git a/examples/csharp/helloworld/Greeter/HelloworldGrpc.cs b/examples/csharp/HelloworldLegacyCsproj/Greeter/HelloworldGrpc.cs similarity index 100% rename from examples/csharp/helloworld/Greeter/HelloworldGrpc.cs rename to examples/csharp/HelloworldLegacyCsproj/Greeter/HelloworldGrpc.cs diff --git a/examples/csharp/helloworld/Greeter/Properties/AssemblyInfo.cs b/examples/csharp/HelloworldLegacyCsproj/Greeter/Properties/AssemblyInfo.cs similarity index 100% rename from examples/csharp/helloworld/Greeter/Properties/AssemblyInfo.cs rename to examples/csharp/HelloworldLegacyCsproj/Greeter/Properties/AssemblyInfo.cs diff --git a/examples/csharp/helloworld/Greeter/packages.config b/examples/csharp/HelloworldLegacyCsproj/Greeter/packages.config similarity index 50% rename from examples/csharp/helloworld/Greeter/packages.config rename to examples/csharp/HelloworldLegacyCsproj/Greeter/packages.config index 38297f8d617..8e61429a8ea 100644 --- a/examples/csharp/helloworld/Greeter/packages.config +++ b/examples/csharp/HelloworldLegacyCsproj/Greeter/packages.config @@ -1,8 +1,8 @@  - - - + + + \ No newline at end of file diff --git a/examples/csharp/helloworld/GreeterClient/.gitignore b/examples/csharp/HelloworldLegacyCsproj/GreeterClient/.gitignore similarity index 100% rename from examples/csharp/helloworld/GreeterClient/.gitignore rename to examples/csharp/HelloworldLegacyCsproj/GreeterClient/.gitignore diff --git a/examples/csharp/helloworld/GreeterClient/GreeterClient.csproj b/examples/csharp/HelloworldLegacyCsproj/GreeterClient/GreeterClient.csproj similarity index 72% rename from examples/csharp/helloworld/GreeterClient/GreeterClient.csproj rename to examples/csharp/HelloworldLegacyCsproj/GreeterClient/GreeterClient.csproj index 470749a2b2b..2d2961d1289 100644 --- a/examples/csharp/helloworld/GreeterClient/GreeterClient.csproj +++ b/examples/csharp/HelloworldLegacyCsproj/GreeterClient/GreeterClient.csproj @@ -36,15 +36,15 @@ ..\packages\Google.Protobuf.3.5.0\lib\net45\Google.Protobuf.dll True - - ..\packages\Grpc.Core.1.8.0\lib\net45\Grpc.Core.dll - True - ..\packages\System.Interactive.Async.3.1.1\lib\net45\System.Interactive.Async.dll True + + ..\packages\Grpc.Core.1.13.1\lib\net45\Grpc.Core.dll + + @@ -60,11 +60,5 @@ - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - + \ No newline at end of file diff --git a/examples/csharp/helloworld/GreeterClient/Program.cs b/examples/csharp/HelloworldLegacyCsproj/GreeterClient/Program.cs similarity index 100% rename from examples/csharp/helloworld/GreeterClient/Program.cs rename to examples/csharp/HelloworldLegacyCsproj/GreeterClient/Program.cs diff --git a/examples/csharp/helloworld/GreeterClient/Properties/AssemblyInfo.cs b/examples/csharp/HelloworldLegacyCsproj/GreeterClient/Properties/AssemblyInfo.cs similarity index 100% rename from examples/csharp/helloworld/GreeterClient/Properties/AssemblyInfo.cs rename to examples/csharp/HelloworldLegacyCsproj/GreeterClient/Properties/AssemblyInfo.cs diff --git a/examples/csharp/helloworld/GreeterClient/packages.config b/examples/csharp/HelloworldLegacyCsproj/GreeterClient/packages.config similarity index 59% rename from examples/csharp/helloworld/GreeterClient/packages.config rename to examples/csharp/HelloworldLegacyCsproj/GreeterClient/packages.config index 4b3684edfd3..da7dbcd8cb5 100644 --- a/examples/csharp/helloworld/GreeterClient/packages.config +++ b/examples/csharp/HelloworldLegacyCsproj/GreeterClient/packages.config @@ -1,7 +1,7 @@  - - + + \ No newline at end of file diff --git a/examples/csharp/helloworld/GreeterServer/.gitignore b/examples/csharp/HelloworldLegacyCsproj/GreeterServer/.gitignore similarity index 100% rename from examples/csharp/helloworld/GreeterServer/.gitignore rename to examples/csharp/HelloworldLegacyCsproj/GreeterServer/.gitignore diff --git a/examples/csharp/helloworld/GreeterServer/GreeterServer.csproj b/examples/csharp/HelloworldLegacyCsproj/GreeterServer/GreeterServer.csproj similarity index 72% rename from examples/csharp/helloworld/GreeterServer/GreeterServer.csproj rename to examples/csharp/HelloworldLegacyCsproj/GreeterServer/GreeterServer.csproj index 82e2961cad2..1d47d705955 100644 --- a/examples/csharp/helloworld/GreeterServer/GreeterServer.csproj +++ b/examples/csharp/HelloworldLegacyCsproj/GreeterServer/GreeterServer.csproj @@ -36,15 +36,15 @@ ..\packages\Google.Protobuf.3.5.0\lib\net45\Google.Protobuf.dll True - - ..\packages\Grpc.Core.1.8.0\lib\net45\Grpc.Core.dll - True - ..\packages\System.Interactive.Async.3.1.1\lib\net45\System.Interactive.Async.dll True + + ..\packages\Grpc.Core.1.13.1\lib\net45\Grpc.Core.dll + + @@ -60,11 +60,5 @@ - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - + \ No newline at end of file diff --git a/examples/csharp/helloworld/GreeterServer/Program.cs b/examples/csharp/HelloworldLegacyCsproj/GreeterServer/Program.cs similarity index 100% rename from examples/csharp/helloworld/GreeterServer/Program.cs rename to examples/csharp/HelloworldLegacyCsproj/GreeterServer/Program.cs diff --git a/examples/csharp/helloworld/GreeterServer/Properties/AssemblyInfo.cs b/examples/csharp/HelloworldLegacyCsproj/GreeterServer/Properties/AssemblyInfo.cs similarity index 100% rename from examples/csharp/helloworld/GreeterServer/Properties/AssemblyInfo.cs rename to examples/csharp/HelloworldLegacyCsproj/GreeterServer/Properties/AssemblyInfo.cs diff --git a/examples/csharp/helloworld/GreeterServer/packages.config b/examples/csharp/HelloworldLegacyCsproj/GreeterServer/packages.config similarity index 59% rename from examples/csharp/helloworld/GreeterServer/packages.config rename to examples/csharp/HelloworldLegacyCsproj/GreeterServer/packages.config index 4b3684edfd3..da7dbcd8cb5 100644 --- a/examples/csharp/helloworld/GreeterServer/packages.config +++ b/examples/csharp/HelloworldLegacyCsproj/GreeterServer/packages.config @@ -1,7 +1,7 @@  - - + + \ No newline at end of file diff --git a/examples/csharp/helloworld/README.md b/examples/csharp/HelloworldLegacyCsproj/README.md similarity index 82% rename from examples/csharp/helloworld/README.md rename to examples/csharp/HelloworldLegacyCsproj/README.md index 55e3ab70305..6d42c5ef258 100644 --- a/examples/csharp/helloworld/README.md +++ b/examples/csharp/HelloworldLegacyCsproj/README.md @@ -3,6 +3,11 @@ gRPC in 3 minutes (C#) BACKGROUND ------------- +This is a different version of the helloworld example, using the old-style .csproj +files supported by VS2013 and VS2015 (and older versions of mono). +You can still use gRPC with the old-style .csproj files, but [using the new-style +.csproj projects](../helloworld/README.md) (supported by VS2017 and dotnet SDK) is recommended. + For this sample, we've already generated the server and client stubs from [helloworld.proto][]. Example projects depend on the [Grpc](https://www.nuget.org/packages/Grpc/), [Grpc.Tools](https://www.nuget.org/packages/Grpc.Tools/) @@ -28,7 +33,7 @@ BUILD # Using Monodevelop or Xamarin Studio The nuget add-in available for Xamarin Studio and Monodevelop IDEs is too old to -download all of the nuget dependencies of gRPC. One alternative to is to use the dotnet command line tools instead (see [helloworld-from-cli]). +download all of the nuget dependencies of gRPC. Using these IDEs, a workaround is as follows: * Obtain a nuget executable for your platform and update it with @@ -62,6 +67,5 @@ Tutorial You can find a more detailed tutorial in [gRPC Basics: C#][] -[helloworld-from-cli]:../helloworld-from-cli/README.md [helloworld.proto]:../../protos/helloworld.proto [gRPC Basics: C#]:https://grpc.io/docs/tutorials/basic/csharp.html diff --git a/examples/csharp/helloworld/generate_protos.bat b/examples/csharp/HelloworldLegacyCsproj/generate_protos.bat similarity index 100% rename from examples/csharp/helloworld/generate_protos.bat rename to examples/csharp/HelloworldLegacyCsproj/generate_protos.bat diff --git a/examples/csharp/route_guide/.gitignore b/examples/csharp/RouteGuide/.gitignore similarity index 100% rename from examples/csharp/route_guide/.gitignore rename to examples/csharp/RouteGuide/.gitignore diff --git a/examples/csharp/route_guide/README.md b/examples/csharp/RouteGuide/README.md similarity index 100% rename from examples/csharp/route_guide/README.md rename to examples/csharp/RouteGuide/README.md diff --git a/examples/csharp/route_guide/RouteGuide.sln b/examples/csharp/RouteGuide/RouteGuide.sln similarity index 87% rename from examples/csharp/route_guide/RouteGuide.sln rename to examples/csharp/RouteGuide/RouteGuide.sln index 00065b0ba9d..73e6e306b16 100644 --- a/examples/csharp/route_guide/RouteGuide.sln +++ b/examples/csharp/RouteGuide/RouteGuide.sln @@ -1,13 +1,13 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.31101.0 +# Visual Studio 15 +VisualStudioVersion = 15.0.26228.4 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RouteGuide", "RouteGuide\RouteGuide.csproj", "{49954D9C-5F17-4662-96B2-73BE833DD81A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RouteGuide", "RouteGuide\RouteGuide.csproj", "{49954D9C-5F17-4662-96B2-73BE833DD81A}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RouteGuideClient", "RouteGuideClient\RouteGuideClient.csproj", "{D47BE663-4DE3-4206-B7A8-EA3FA066DADC}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RouteGuideClient", "RouteGuideClient\RouteGuideClient.csproj", "{D47BE663-4DE3-4206-B7A8-EA3FA066DADC}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RouteGuideServer", "RouteGuideServer\RouteGuideServer.csproj", "{4B7C7794-BE24-4477-ACE7-18259EB73D27}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RouteGuideServer", "RouteGuideServer\RouteGuideServer.csproj", "{4B7C7794-BE24-4477-ACE7-18259EB73D27}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/examples/csharp/route_guide/RouteGuide/RouteGuide.cs b/examples/csharp/RouteGuide/RouteGuide/RouteGuide.cs similarity index 100% rename from examples/csharp/route_guide/RouteGuide/RouteGuide.cs rename to examples/csharp/RouteGuide/RouteGuide/RouteGuide.cs diff --git a/examples/csharp/RouteGuide/RouteGuide/RouteGuide.csproj b/examples/csharp/RouteGuide/RouteGuide/RouteGuide.csproj new file mode 100644 index 00000000000..7419f1a277d --- /dev/null +++ b/examples/csharp/RouteGuide/RouteGuide/RouteGuide.csproj @@ -0,0 +1,25 @@ + + + + RouteGuide + netcoreapp1.0 + portable + RouteGuide + RouteGuide + + + + + + + + + + + + + PreserveNewest + + + + diff --git a/examples/csharp/route_guide/RouteGuide/RouteGuideGrpc.cs b/examples/csharp/RouteGuide/RouteGuide/RouteGuideGrpc.cs similarity index 100% rename from examples/csharp/route_guide/RouteGuide/RouteGuideGrpc.cs rename to examples/csharp/RouteGuide/RouteGuide/RouteGuideGrpc.cs diff --git a/examples/csharp/route_guide/RouteGuide/RouteGuideUtil.cs b/examples/csharp/RouteGuide/RouteGuide/RouteGuideUtil.cs similarity index 100% rename from examples/csharp/route_guide/RouteGuide/RouteGuideUtil.cs rename to examples/csharp/RouteGuide/RouteGuide/RouteGuideUtil.cs diff --git a/examples/csharp/route_guide/RouteGuide/route_guide_db.json b/examples/csharp/RouteGuide/RouteGuide/route_guide_db.json similarity index 100% rename from examples/csharp/route_guide/RouteGuide/route_guide_db.json rename to examples/csharp/RouteGuide/RouteGuide/route_guide_db.json diff --git a/examples/csharp/route_guide/RouteGuideClient/Program.cs b/examples/csharp/RouteGuide/RouteGuideClient/Program.cs similarity index 100% rename from examples/csharp/route_guide/RouteGuideClient/Program.cs rename to examples/csharp/RouteGuide/RouteGuideClient/Program.cs diff --git a/examples/csharp/RouteGuide/RouteGuideClient/RouteGuideClient.csproj b/examples/csharp/RouteGuide/RouteGuideClient/RouteGuideClient.csproj new file mode 100644 index 00000000000..96cc204ba37 --- /dev/null +++ b/examples/csharp/RouteGuide/RouteGuideClient/RouteGuideClient.csproj @@ -0,0 +1,16 @@ + + + + RouteGuideClient + netcoreapp1.0 + portable + RouteGuideClient + Exe + RouteGuideClient + + + + + + + diff --git a/examples/csharp/route_guide/RouteGuideServer/Program.cs b/examples/csharp/RouteGuide/RouteGuideServer/Program.cs similarity index 100% rename from examples/csharp/route_guide/RouteGuideServer/Program.cs rename to examples/csharp/RouteGuide/RouteGuideServer/Program.cs diff --git a/examples/csharp/route_guide/RouteGuideServer/RouteGuideImpl.cs b/examples/csharp/RouteGuide/RouteGuideServer/RouteGuideImpl.cs similarity index 100% rename from examples/csharp/route_guide/RouteGuideServer/RouteGuideImpl.cs rename to examples/csharp/RouteGuide/RouteGuideServer/RouteGuideImpl.cs diff --git a/examples/csharp/RouteGuide/RouteGuideServer/RouteGuideServer.csproj b/examples/csharp/RouteGuide/RouteGuideServer/RouteGuideServer.csproj new file mode 100644 index 00000000000..aa6315bf818 --- /dev/null +++ b/examples/csharp/RouteGuide/RouteGuideServer/RouteGuideServer.csproj @@ -0,0 +1,16 @@ + + + + RouteGuideServer + netcoreapp1.0 + portable + RouteGuideServer + Exe + RouteGuideServer + + + + + + + diff --git a/examples/csharp/route_guide/generate_protos.bat b/examples/csharp/RouteGuide/generate_protos.bat similarity index 100% rename from examples/csharp/route_guide/generate_protos.bat rename to examples/csharp/RouteGuide/generate_protos.bat diff --git a/examples/csharp/route_guide/RouteGuide/Properties/AssemblyInfo.cs b/examples/csharp/route_guide/RouteGuide/Properties/AssemblyInfo.cs deleted file mode 100644 index dfee25c14cf..00000000000 --- a/examples/csharp/route_guide/RouteGuide/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,54 +0,0 @@ -#region Copyright notice and license - -// Copyright 2015 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.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("RouteGuide")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("RouteGuide")] -[assembly: AssemblyCopyright("Copyright © 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("ef6b85bc-ac27-46de-8714-a658236cc6fb")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/examples/csharp/route_guide/RouteGuide/RouteGuide.csproj b/examples/csharp/route_guide/RouteGuide/RouteGuide.csproj deleted file mode 100644 index e66e986f71f..00000000000 --- a/examples/csharp/route_guide/RouteGuide/RouteGuide.csproj +++ /dev/null @@ -1,92 +0,0 @@ - - - - - Debug - AnyCPU - {49954D9C-5F17-4662-96B2-73BE833DD81A} - Library - Properties - RouteGuide - RouteGuide - v4.5 - 512 - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\Google.Protobuf.3.5.0\lib\net45\Google.Protobuf.dll - True - - - ..\packages\Grpc.Core.1.8.0\lib\net45\Grpc.Core.dll - True - - - False - ..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll - - - - - ..\packages\System.Interactive.Async.3.1.1\lib\net45\System.Interactive.Async.dll - True - - - - - - - - - - - - - - - - protos\route_guide.proto - - - generate_protos.bat - - - - PreserveNewest - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - \ No newline at end of file diff --git a/examples/csharp/route_guide/RouteGuide/packages.config b/examples/csharp/route_guide/RouteGuide/packages.config deleted file mode 100644 index fe2c995f262..00000000000 --- a/examples/csharp/route_guide/RouteGuide/packages.config +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/examples/csharp/route_guide/RouteGuideClient/Properties/AssemblyInfo.cs b/examples/csharp/route_guide/RouteGuideClient/Properties/AssemblyInfo.cs deleted file mode 100644 index 4ccdf701d3f..00000000000 --- a/examples/csharp/route_guide/RouteGuideClient/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,54 +0,0 @@ -#region Copyright notice and license - -// Copyright 2015 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.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("RouteGuideClient")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("RouteGuideClient")] -[assembly: AssemblyCopyright("Copyright © 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("914644eb-47cd-4a37-9fba-5e62dd432333")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/examples/csharp/route_guide/RouteGuideClient/RouteGuideClient.csproj b/examples/csharp/route_guide/RouteGuideClient/RouteGuideClient.csproj deleted file mode 100644 index 612f60cba58..00000000000 --- a/examples/csharp/route_guide/RouteGuideClient/RouteGuideClient.csproj +++ /dev/null @@ -1,89 +0,0 @@ - - - - - Debug - AnyCPU - {D47BE663-4DE3-4206-B7A8-EA3FA066DADC} - Exe - Properties - RouteGuideClient - RouteGuideClient - v4.5 - 512 - - - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\Google.Protobuf.3.5.0\lib\net45\Google.Protobuf.dll - True - - - ..\packages\Grpc.Core.1.8.0\lib\net45\Grpc.Core.dll - True - - - False - ..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll - - - - - ..\packages\System.Interactive.Async.3.1.1\lib\net45\System.Interactive.Async.dll - True - - - - - - - - - - - - - - - - - {49954d9c-5f17-4662-96b2-73be833dd81a} - RouteGuide - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - \ No newline at end of file diff --git a/examples/csharp/route_guide/RouteGuideClient/packages.config b/examples/csharp/route_guide/RouteGuideClient/packages.config deleted file mode 100644 index fe2c995f262..00000000000 --- a/examples/csharp/route_guide/RouteGuideClient/packages.config +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/examples/csharp/route_guide/RouteGuideServer/Properties/AssemblyInfo.cs b/examples/csharp/route_guide/RouteGuideServer/Properties/AssemblyInfo.cs deleted file mode 100644 index 679bc4c9131..00000000000 --- a/examples/csharp/route_guide/RouteGuideServer/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,54 +0,0 @@ -#region Copyright notice and license - -// Copyright 2015 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.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("RouteGuideServer")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("RouteGuideServer")] -[assembly: AssemblyCopyright("Copyright © 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("908bdeef-05cc-42bf-9498-c4c573df8925")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/examples/csharp/route_guide/RouteGuideServer/RouteGuideServer.csproj b/examples/csharp/route_guide/RouteGuideServer/RouteGuideServer.csproj deleted file mode 100644 index 4d9d9d74f2c..00000000000 --- a/examples/csharp/route_guide/RouteGuideServer/RouteGuideServer.csproj +++ /dev/null @@ -1,90 +0,0 @@ - - - - - Debug - AnyCPU - {4B7C7794-BE24-4477-ACE7-18259EB73D27} - Exe - Properties - RouteGuideServer - RouteGuideServer - v4.5 - 512 - - - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\Google.Protobuf.3.5.0\lib\net45\Google.Protobuf.dll - True - - - ..\packages\Grpc.Core.1.8.0\lib\net45\Grpc.Core.dll - True - - - False - ..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll - - - - - ..\packages\System.Interactive.Async.3.1.1\lib\net45\System.Interactive.Async.dll - True - - - - - - - - - - - - - - - - - - {49954d9c-5f17-4662-96b2-73be833dd81a} - RouteGuide - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - \ No newline at end of file diff --git a/examples/csharp/route_guide/RouteGuideServer/packages.config b/examples/csharp/route_guide/RouteGuideServer/packages.config deleted file mode 100644 index 2bb1f0d0bf0..00000000000 --- a/examples/csharp/route_guide/RouteGuideServer/packages.config +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/include/grpc/grpc_security.h b/include/grpc/grpc_security.h index 102d20fcf98..02d87a493a1 100644 --- a/include/grpc/grpc_security.h +++ b/include/grpc/grpc_security.h @@ -587,12 +587,6 @@ GRPCAPI grpc_server_credentials* grpc_alts_server_credentials_create( /** --- Local channel/server credentials --- **/ -/** - * Type of local connection for which local channel/server credentials will be - * applied. It only supports UDS for now. - */ -typedef enum { UDS = 0 } grpc_local_connect_type; - /** * This method creates a local channel credential object. It is used for * experimental purpose for now and subject to change. diff --git a/include/grpc/grpc_security_constants.h b/include/grpc/grpc_security_constants.h index 92580ea35e9..944a1e927f0 100644 --- a/include/grpc/grpc_security_constants.h +++ b/include/grpc/grpc_security_constants.h @@ -100,6 +100,12 @@ typedef enum { GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY } grpc_ssl_client_certificate_request_type; +/** + * Type of local connection for which local channel/server credentials will be + * applied. It only supports UDS for now. + */ +typedef enum { UDS = 0 } grpc_local_connect_type; + #ifdef __cplusplus } #endif diff --git a/include/grpcpp/security/credentials.h b/include/grpcpp/security/credentials.h index 36d95d1b426..bfadc15df57 100644 --- a/include/grpcpp/security/credentials.h +++ b/include/grpcpp/security/credentials.h @@ -23,6 +23,7 @@ #include #include +#include #include #include #include @@ -234,6 +235,10 @@ struct AltsCredentialsOptions { std::shared_ptr AltsCredentials( const AltsCredentialsOptions& options); +/// Builds Local Credentials. +std::shared_ptr LocalCredentials( + grpc_local_connect_type type); + } // namespace experimental } // namespace grpc diff --git a/include/grpcpp/security/server_credentials.h b/include/grpcpp/security/server_credentials.h index cf57e275f59..bd00a0a1737 100644 --- a/include/grpcpp/security/server_credentials.h +++ b/include/grpcpp/security/server_credentials.h @@ -97,6 +97,10 @@ struct AltsServerCredentialsOptions { std::shared_ptr AltsServerCredentials( const AltsServerCredentialsOptions& options); +/// Builds Local ServerCredentials. +std::shared_ptr LocalServerCredentials( + grpc_local_connect_type type); + } // namespace experimental } // namespace grpc diff --git a/src/core/lib/gprpp/ref_counted_ptr.h b/src/core/lib/gprpp/ref_counted_ptr.h index 91ca8eae63d..c2dfbdd90f0 100644 --- a/src/core/lib/gprpp/ref_counted_ptr.h +++ b/src/core/lib/gprpp/ref_counted_ptr.h @@ -41,21 +41,23 @@ class RefCountedPtr { value_ = value; } - // Move support. + // Move ctors. RefCountedPtr(RefCountedPtr&& other) { value_ = other.value_; other.value_ = nullptr; } - RefCountedPtr& operator=(RefCountedPtr&& other) { - if (value_ != nullptr) value_->Unref(); + template + RefCountedPtr(RefCountedPtr&& other) { value_ = other.value_; other.value_ = nullptr; - return *this; } - template - RefCountedPtr(RefCountedPtr&& other) { + + // Move assignment. + RefCountedPtr& operator=(RefCountedPtr&& other) { + if (value_ != nullptr) value_->Unref(); value_ = other.value_; other.value_ = nullptr; + return *this; } template RefCountedPtr& operator=(RefCountedPtr&& other) { @@ -65,11 +67,18 @@ class RefCountedPtr { return *this; } - // Copy support. + // Copy ctors. RefCountedPtr(const RefCountedPtr& other) { if (other.value_ != nullptr) other.value_->IncrementRefCount(); value_ = other.value_; } + template + RefCountedPtr(const RefCountedPtr& other) { + if (other.value_ != nullptr) other.value_->IncrementRefCount(); + value_ = other.value_; + } + + // Copy assignment. RefCountedPtr& operator=(const RefCountedPtr& other) { // Note: Order of reffing and unreffing is important here in case value_ // and other.value_ are the same object. @@ -79,11 +88,6 @@ class RefCountedPtr { return *this; } template - RefCountedPtr(const RefCountedPtr& other) { - if (other.value_ != nullptr) other.value_->IncrementRefCount(); - value_ = other.value_; - } - template RefCountedPtr& operator=(const RefCountedPtr& other) { // Note: Order of reffing and unreffing is important here in case value_ // and other.value_ are the same object. diff --git a/src/core/lib/iomgr/ev_epoll1_linux.cc b/src/core/lib/iomgr/ev_epoll1_linux.cc index 86a0243d2ef..ecb7eadf85d 100644 --- a/src/core/lib/iomgr/ev_epoll1_linux.cc +++ b/src/core/lib/iomgr/ev_epoll1_linux.cc @@ -140,10 +140,6 @@ struct grpc_fd { struct grpc_fd* freelist_next; - /* The pollset that last noticed that the fd is readable. The actual type - * stored in this is (grpc_pollset *) */ - gpr_atm read_notifier_pollset; - grpc_iomgr_object iomgr_object; }; @@ -293,7 +289,6 @@ static grpc_fd* fd_create(int fd, const char* name, bool track_err) { new_fd->read_closure->InitEvent(); new_fd->write_closure->InitEvent(); new_fd->error_closure->InitEvent(); - gpr_atm_no_barrier_store(&new_fd->read_notifier_pollset, (gpr_atm)NULL); new_fd->freelist_next = nullptr; @@ -376,11 +371,6 @@ static void fd_orphan(grpc_fd* fd, grpc_closure* on_done, int* release_fd, gpr_mu_unlock(&fd_freelist_mu); } -static grpc_pollset* fd_get_read_notifier_pollset(grpc_fd* fd) { - gpr_atm notifier = gpr_atm_acq_load(&fd->read_notifier_pollset); - return (grpc_pollset*)notifier; -} - static bool fd_is_shutdown(grpc_fd* fd) { return fd->read_closure->IsShutdown(); } @@ -397,11 +387,7 @@ static void fd_notify_on_error(grpc_fd* fd, grpc_closure* closure) { fd->error_closure->NotifyOn(closure); } -static void fd_become_readable(grpc_fd* fd, grpc_pollset* notifier) { - fd->read_closure->SetReady(); - /* Use release store to match with acquire load in fd_get_read_notifier */ - gpr_atm_rel_store(&fd->read_notifier_pollset, (gpr_atm)notifier); -} +static void fd_become_readable(grpc_fd* fd) { fd->read_closure->SetReady(); } static void fd_become_writable(grpc_fd* fd) { fd->write_closure->SetReady(); } @@ -642,7 +628,7 @@ static grpc_error* process_epoll_events(grpc_pollset* pollset) { } if (read_ev || cancel || err_fallback) { - fd_become_readable(fd, pollset); + fd_become_readable(fd); } if (write_ev || cancel || err_fallback) { @@ -1218,7 +1204,6 @@ static const grpc_event_engine_vtable vtable = { fd_notify_on_write, fd_notify_on_error, fd_is_shutdown, - fd_get_read_notifier_pollset, pollset_init, pollset_shutdown, diff --git a/src/core/lib/iomgr/ev_epollex_linux.cc b/src/core/lib/iomgr/ev_epollex_linux.cc index e1f3e43af79..6ec8267799f 100644 --- a/src/core/lib/iomgr/ev_epollex_linux.cc +++ b/src/core/lib/iomgr/ev_epollex_linux.cc @@ -220,10 +220,6 @@ struct grpc_fd { struct grpc_fd* freelist_next; grpc_closure* on_done_closure; - // The pollset that last noticed that the fd is readable. The actual type - // stored in this is (grpc_pollset *) - gpr_atm read_notifier_pollset; - grpc_iomgr_object iomgr_object; // Do we need to track EPOLLERR events separately? @@ -353,7 +349,6 @@ static void invalidate_fd(grpc_fd* fd) { memset(&fd->pollable_mu, -1, sizeof(fd->pollable_mu)); fd->pollable_obj = nullptr; fd->on_done_closure = nullptr; - gpr_atm_no_barrier_store(&fd->read_notifier_pollset, 0); memset(&fd->iomgr_object, -1, sizeof(fd->iomgr_object)); fd->track_err = false; } @@ -445,7 +440,6 @@ static grpc_fd* fd_create(int fd, const char* name, bool track_err) { new_fd->error_closure->InitEvent(); new_fd->freelist_next = nullptr; new_fd->on_done_closure = nullptr; - gpr_atm_no_barrier_store(&new_fd->read_notifier_pollset, (gpr_atm)NULL); char* fd_name; gpr_asprintf(&fd_name, "%s fd=%d", name, fd); @@ -514,11 +508,6 @@ static void fd_orphan(grpc_fd* fd, grpc_closure* on_done, int* release_fd, UNREF_BY(fd, 2, reason); /* Drop the reference */ } -static grpc_pollset* fd_get_read_notifier_pollset(grpc_fd* fd) { - gpr_atm notifier = gpr_atm_acq_load(&fd->read_notifier_pollset); - return (grpc_pollset*)notifier; -} - static bool fd_is_shutdown(grpc_fd* fd) { return fd->read_closure->IsShutdown(); } @@ -875,17 +864,7 @@ static int poll_deadline_to_millis_timeout(grpc_millis millis) { return static_cast(delta); } -static void fd_become_readable(grpc_fd* fd, grpc_pollset* notifier) { - fd->read_closure->SetReady(); - - /* Note, it is possible that fd_become_readable might be called twice with - different 'notifier's when an fd becomes readable and it is in two epoll - sets (This can happen briefly during polling island merges). In such cases - it does not really matter which notifer is set as the read_notifier_pollset - (They would both point to the same polling island anyway) */ - /* Use release store to match with acquire load in fd_get_read_notifier */ - gpr_atm_rel_store(&fd->read_notifier_pollset, (gpr_atm)notifier); -} +static void fd_become_readable(grpc_fd* fd) { fd->read_closure->SetReady(); } static void fd_become_writable(grpc_fd* fd) { fd->write_closure->SetReady(); } @@ -983,7 +962,7 @@ static grpc_error* pollable_process_events(grpc_pollset* pollset, fd_has_errors(fd); } if (read_ev || cancel || err_fallback) { - fd_become_readable(fd, pollset); + fd_become_readable(fd); } if (write_ev || cancel || err_fallback) { fd_become_writable(fd); @@ -1637,7 +1616,6 @@ static const grpc_event_engine_vtable vtable = { fd_notify_on_write, fd_notify_on_error, fd_is_shutdown, - fd_get_read_notifier_pollset, pollset_init, pollset_shutdown, diff --git a/src/core/lib/iomgr/ev_epollsig_linux.cc b/src/core/lib/iomgr/ev_epollsig_linux.cc index 2189801c187..28656b06661 100644 --- a/src/core/lib/iomgr/ev_epollsig_linux.cc +++ b/src/core/lib/iomgr/ev_epollsig_linux.cc @@ -137,10 +137,6 @@ struct grpc_fd { struct grpc_fd* freelist_next; grpc_closure* on_done_closure; - /* The pollset that last noticed that the fd is readable. The actual type - * stored in this is (grpc_pollset *) */ - gpr_atm read_notifier_pollset; - grpc_iomgr_object iomgr_object; /* Do we need to track EPOLLERR events separately? */ @@ -845,7 +841,6 @@ static grpc_fd* fd_create(int fd, const char* name, bool track_err) { new_fd->write_closure->InitEvent(); new_fd->error_closure->InitEvent(); new_fd->track_err = track_err; - gpr_atm_no_barrier_store(&new_fd->read_notifier_pollset, (gpr_atm)NULL); new_fd->freelist_next = nullptr; new_fd->on_done_closure = nullptr; @@ -927,11 +922,6 @@ static void fd_orphan(grpc_fd* fd, grpc_closure* on_done, int* release_fd, GRPC_ERROR_UNREF(error); } -static grpc_pollset* fd_get_read_notifier_pollset(grpc_fd* fd) { - gpr_atm notifier = gpr_atm_acq_load(&fd->read_notifier_pollset); - return (grpc_pollset*)notifier; -} - static bool fd_is_shutdown(grpc_fd* fd) { return fd->read_closure->IsShutdown(); } @@ -1115,17 +1105,7 @@ static int poll_deadline_to_millis_timeout(grpc_millis millis) { return static_cast(delta); } -static void fd_become_readable(grpc_fd* fd, grpc_pollset* notifier) { - fd->read_closure->SetReady(); - - /* Note, it is possible that fd_become_readable might be called twice with - different 'notifier's when an fd becomes readable and it is in two epoll - sets (This can happen briefly during polling island merges). In such cases - it does not really matter which notifer is set as the read_notifier_pollset - (They would both point to the same polling island anyway) */ - /* Use release store to match with acquire load in fd_get_read_notifier */ - gpr_atm_rel_store(&fd->read_notifier_pollset, (gpr_atm)notifier); -} +static void fd_become_readable(grpc_fd* fd) { fd->read_closure->SetReady(); } static void fd_become_writable(grpc_fd* fd) { fd->write_closure->SetReady(); } @@ -1283,7 +1263,7 @@ static void pollset_work_and_unlock(grpc_pollset* pollset, fd_has_errors(fd); } if (read_ev || cancel || err_fallback) { - fd_become_readable(fd, pollset); + fd_become_readable(fd); } if (write_ev || cancel || err_fallback) { fd_become_writable(fd); @@ -1668,7 +1648,6 @@ static const grpc_event_engine_vtable vtable = { fd_notify_on_write, fd_notify_on_error, fd_is_shutdown, - fd_get_read_notifier_pollset, pollset_init, pollset_shutdown, diff --git a/src/core/lib/iomgr/ev_poll_posix.cc b/src/core/lib/iomgr/ev_poll_posix.cc index c9c09881a2a..a4a83c4ad7e 100644 --- a/src/core/lib/iomgr/ev_poll_posix.cc +++ b/src/core/lib/iomgr/ev_poll_posix.cc @@ -108,9 +108,6 @@ struct grpc_fd { grpc_closure* on_done_closure; grpc_iomgr_object iomgr_object; - - /* The pollset that last noticed and notified that the fd is readable */ - grpc_pollset* read_notifier_pollset; }; /* Begin polling on an fd. @@ -131,8 +128,7 @@ static uint32_t fd_begin_poll(grpc_fd* fd, grpc_pollset* pollset, MUST NOT be called with a pollset lock taken if got_read or got_write are 1, also does the become_{readable,writable} as appropriate. */ -static void fd_end_poll(grpc_fd_watcher* rec, int got_read, int got_write, - grpc_pollset* read_notifier_pollset); +static void fd_end_poll(grpc_fd_watcher* rec, int got_read, int got_write); /* Return 1 if this fd is orphaned, 0 otherwise */ static bool fd_is_orphaned(grpc_fd* fd); @@ -346,7 +342,6 @@ static grpc_fd* fd_create(int fd, const char* name, bool track_err) { r->closed = 0; r->released = 0; gpr_atm_no_barrier_store(&r->pollhup, 0); - r->read_notifier_pollset = nullptr; char* name2; gpr_asprintf(&name2, "%s fd=%d", name, fd); @@ -359,17 +354,6 @@ static bool fd_is_orphaned(grpc_fd* fd) { return (gpr_atm_acq_load(&fd->refst) & 1) == 0; } -/* Return the read-notifier pollset */ -static grpc_pollset* fd_get_read_notifier_pollset(grpc_fd* fd) { - grpc_pollset* notifier = nullptr; - - gpr_mu_lock(&fd->mu); - notifier = fd->read_notifier_pollset; - gpr_mu_unlock(&fd->mu); - - return notifier; -} - static grpc_error* pollset_kick_locked(grpc_fd_watcher* watcher) { gpr_mu_lock(&watcher->pollset->mu); GPR_ASSERT(watcher->worker); @@ -512,11 +496,6 @@ static int set_ready_locked(grpc_fd* fd, grpc_closure** st) { } } -static void set_read_notifier_pollset_locked( - grpc_fd* fd, grpc_pollset* read_notifier_pollset) { - fd->read_notifier_pollset = read_notifier_pollset; -} - static void fd_shutdown(grpc_fd* fd, grpc_error* why) { gpr_mu_lock(&fd->mu); /* only shutdown once */ @@ -553,8 +532,10 @@ static void fd_notify_on_write(grpc_fd* fd, grpc_closure* closure) { } static void fd_notify_on_error(grpc_fd* fd, grpc_closure* closure) { - gpr_log(GPR_ERROR, "Polling engine does not support tracking errors."); - abort(); + if (grpc_polling_trace.enabled()) { + gpr_log(GPR_ERROR, "Polling engine does not support tracking errors."); + } + GRPC_CLOSURE_SCHED(closure, GRPC_ERROR_CANCELLED); } static uint32_t fd_begin_poll(grpc_fd* fd, grpc_pollset* pollset, @@ -608,8 +589,7 @@ static uint32_t fd_begin_poll(grpc_fd* fd, grpc_pollset* pollset, return mask; } -static void fd_end_poll(grpc_fd_watcher* watcher, int got_read, int got_write, - grpc_pollset* read_notifier_pollset) { +static void fd_end_poll(grpc_fd_watcher* watcher, int got_read, int got_write) { int was_polling = 0; int kick = 0; grpc_fd* fd = watcher->fd; @@ -645,9 +625,6 @@ static void fd_end_poll(grpc_fd_watcher* watcher, int got_read, int got_write, if (set_ready_locked(fd, &fd->read_closure)) { kick = 1; } - if (read_notifier_pollset != nullptr) { - set_read_notifier_pollset_locked(fd, read_notifier_pollset); - } } if (got_write) { if (set_ready_locked(fd, &fd->write_closure)) { @@ -997,16 +974,16 @@ static grpc_error* pollset_work(grpc_pollset* pollset, for (i = 1; i < pfd_count; i++) { if (watchers[i].fd == nullptr) { - fd_end_poll(&watchers[i], 0, 0, nullptr); + fd_end_poll(&watchers[i], 0, 0); } else { // Wake up all the file descriptors, if we have an invalid one // we can identify it on the next pollset_work() - fd_end_poll(&watchers[i], 1, 1, pollset); + fd_end_poll(&watchers[i], 1, 1); } } } else if (r == 0) { for (i = 1; i < pfd_count; i++) { - fd_end_poll(&watchers[i], 0, 0, nullptr); + fd_end_poll(&watchers[i], 0, 0); } } else { if (pfds[0].revents & POLLIN_CHECK) { @@ -1018,7 +995,7 @@ static grpc_error* pollset_work(grpc_pollset* pollset, } for (i = 1; i < pfd_count; i++) { if (watchers[i].fd == nullptr) { - fd_end_poll(&watchers[i], 0, 0, nullptr); + fd_end_poll(&watchers[i], 0, 0); } else { if (grpc_polling_trace.enabled()) { gpr_log(GPR_INFO, "%p got_event: %d r:%d w:%d [%d]", pollset, @@ -1032,7 +1009,7 @@ static grpc_error* pollset_work(grpc_pollset* pollset, gpr_atm_no_barrier_store(&watchers[i].fd->pollhup, 1); } fd_end_poll(&watchers[i], pfds[i].revents & POLLIN_CHECK, - pfds[i].revents & POLLOUT_CHECK, pollset); + pfds[i].revents & POLLOUT_CHECK); } } } @@ -1724,7 +1701,6 @@ static const grpc_event_engine_vtable vtable = { fd_notify_on_write, fd_notify_on_error, fd_is_shutdown, - fd_get_read_notifier_pollset, pollset_init, pollset_shutdown, diff --git a/src/core/lib/iomgr/ev_posix.h b/src/core/lib/iomgr/ev_posix.h index b4c17fc80df..393c3dd05ef 100644 --- a/src/core/lib/iomgr/ev_posix.h +++ b/src/core/lib/iomgr/ev_posix.h @@ -52,7 +52,6 @@ typedef struct grpc_event_engine_vtable { void (*fd_notify_on_write)(grpc_fd* fd, grpc_closure* closure); void (*fd_notify_on_error)(grpc_fd* fd, grpc_closure* closure); bool (*fd_is_shutdown)(grpc_fd* fd); - grpc_pollset* (*fd_get_read_notifier_pollset)(grpc_fd* fd); void (*pollset_init)(grpc_pollset* pollset, gpr_mu** mu); void (*pollset_shutdown)(grpc_pollset* pollset, grpc_closure* closure); @@ -142,9 +141,6 @@ void grpc_fd_notify_on_write(grpc_fd* fd, grpc_closure* closure); * needs to have been set on grpc_fd_create */ void grpc_fd_notify_on_error(grpc_fd* fd, grpc_closure* closure); -/* Return the read notifier pollset from the fd */ -grpc_pollset* grpc_fd_get_read_notifier_pollset(grpc_fd* fd); - /* pollset_posix functions */ /* Add an fd to a pollset */ diff --git a/src/cpp/client/secure_credentials.cc b/src/cpp/client/secure_credentials.cc index bdb63596326..e48fbeb86d7 100644 --- a/src/cpp/client/secure_credentials.cc +++ b/src/cpp/client/secure_credentials.cc @@ -107,6 +107,13 @@ std::shared_ptr AltsCredentials( return WrapChannelCredentials(c_creds); } +// Builds Local Credentials +std::shared_ptr LocalCredentials( + grpc_local_connect_type type) { + GrpcLibraryCodegen init; // To call grpc_init(). + return WrapChannelCredentials(grpc_local_credentials_create(type)); +} + } // namespace experimental // Builds credentials for use when running in GCE diff --git a/src/cpp/server/secure_server_credentials.cc b/src/cpp/server/secure_server_credentials.cc index a5af25751af..536bf022dde 100644 --- a/src/cpp/server/secure_server_credentials.cc +++ b/src/cpp/server/secure_server_credentials.cc @@ -139,5 +139,11 @@ std::shared_ptr AltsServerCredentials( new SecureServerCredentials(c_creds)); } +std::shared_ptr LocalServerCredentials( + grpc_local_connect_type type) { + return std::shared_ptr( + new SecureServerCredentials(grpc_local_server_credentials_create(type))); +} + } // namespace experimental } // namespace grpc diff --git a/src/objective-c/tests/build_one_example.sh b/src/objective-c/tests/build_one_example.sh index 1eace541e6c..084147f1d46 100755 --- a/src/objective-c/tests/build_one_example.sh +++ b/src/objective-c/tests/build_one_example.sh @@ -43,7 +43,7 @@ xcodebuild \ -workspace *.xcworkspace \ -scheme $SCHEME \ -destination generic/platform=iOS \ - -derivedDataPath Build \ + -derivedDataPath Build/Build \ CODE_SIGN_IDENTITY="" \ CODE_SIGNING_REQUIRED=NO \ | egrep -v "$XCODEBUILD_FILTER" \ diff --git a/test/core/gprpp/ref_counted_ptr_test.cc b/test/core/gprpp/ref_counted_ptr_test.cc index 6df6e348c6f..463b5e89667 100644 --- a/test/core/gprpp/ref_counted_ptr_test.cc +++ b/test/core/gprpp/ref_counted_ptr_test.cc @@ -175,28 +175,65 @@ TEST(RefCountedPtr, RefCountedWithTracing) { foo->Unref(DEBUG_LOCATION, "foo"); } -class Parent : public RefCounted { +class BaseClass : public RefCounted { public: - Parent() {} + BaseClass() {} }; -class Child : public Parent { +class Subclass : public BaseClass { public: - Child() {} + Subclass() {} }; -void FunctionTakingParent(RefCountedPtr o) {} +TEST(RefCountedPtr, ConstructFromSubclass) { + RefCountedPtr p(New()); +} + +TEST(RefCountedPtr, CopyAssignFromSubclass) { + RefCountedPtr b; + EXPECT_EQ(nullptr, b.get()); + RefCountedPtr s = MakeRefCounted(); + b = s; + EXPECT_NE(nullptr, b.get()); +} + +TEST(RefCountedPtr, MoveAssignFromSubclass) { + RefCountedPtr b; + EXPECT_EQ(nullptr, b.get()); + RefCountedPtr s = MakeRefCounted(); + b = std::move(s); + EXPECT_NE(nullptr, b.get()); +} + +TEST(RefCountedPtr, ResetFromSubclass) { + RefCountedPtr b; + EXPECT_EQ(nullptr, b.get()); + b.reset(New()); + EXPECT_NE(nullptr, b.get()); +} + +TEST(RefCountedPtr, EqualityWithSubclass) { + Subclass* s = New(); + RefCountedPtr b(s); + EXPECT_EQ(b, s); +} -void FunctionTakingChild(RefCountedPtr o) {} +void FunctionTakingBaseClass(RefCountedPtr p) { + p.reset(); // To appease clang-tidy. +} + +TEST(RefCountedPtr, CanPassSubclassToFunctionExpectingBaseClass) { + RefCountedPtr p = MakeRefCounted(); + FunctionTakingBaseClass(p); +} -TEST(RefCountedPtr, CanPassChildToFunctionExpectingParent) { - RefCountedPtr child = MakeRefCounted(); - FunctionTakingParent(child); +void FunctionTakingSubclass(RefCountedPtr p) { + p.reset(); // To appease clang-tidy. } -TEST(RefCountedPtr, CanPassChildToFunctionExpectingChild) { - RefCountedPtr child = MakeRefCounted(); - FunctionTakingChild(child); +TEST(RefCountedPtr, CanPassSubclassToFunctionExpectingSubclass) { + RefCountedPtr p = MakeRefCounted(); + FunctionTakingSubclass(p); } } // namespace diff --git a/tools/internal_ci/helper_scripts/prepare_build_macos_rc b/tools/internal_ci/helper_scripts/prepare_build_macos_rc index bc7fff1b144..cbc42f52956 100644 --- a/tools/internal_ci/helper_scripts/prepare_build_macos_rc +++ b/tools/internal_ci/helper_scripts/prepare_build_macos_rc @@ -89,3 +89,7 @@ export DOTNET_CLI_TELEMETRY_OPTOUT=true date git submodule update --init + +# Store intermediate build files of ios binary size test into /tmpfs +mkdir /tmpfs/Build-ios-binary-size +ln -s /tmpfs/Build-ios-binary-size src/objective-c/examples/Sample/Build diff --git a/tools/profiling/ios_bin/binary_size.py b/tools/profiling/ios_bin/binary_size.py index b07adb57345..91c43f44243 100755 --- a/tools/profiling/ios_bin/binary_size.py +++ b/tools/profiling/ios_bin/binary_size.py @@ -55,7 +55,7 @@ def dir_size(dir): def get_size(where, frameworks): - build_dir = 'src/objective-c/examples/Sample/Build-%s/' % where + build_dir = 'src/objective-c/examples/Sample/Build/Build-%s/' % where if not frameworks: link_map_filename = 'Build/Intermediates.noindex/Sample.build/Release-iphoneos/Sample.build/Sample-LinkMap-normal-arm64.txt' return parse_link_map(build_dir + link_map_filename) @@ -76,14 +76,15 @@ def get_size(where, frameworks): def build(where, frameworks): shutil.rmtree( - 'src/objective-c/examples/Sample/Build-%s' % where, ignore_errors=True) + 'src/objective-c/examples/Sample/Build/Build-%s' % where, + ignore_errors=True) subprocess.check_call( 'CONFIG=opt EXAMPLE_PATH=src/objective-c/examples/Sample SCHEME=Sample FRAMEWORKS=%s ./build_one_example.sh' % ('YES' if frameworks else 'NO'), shell=True, cwd='src/objective-c/tests') - os.rename('src/objective-c/examples/Sample/Build', - 'src/objective-c/examples/Sample/Build-%s' % where) + os.rename('src/objective-c/examples/Sample/Build/Build', + 'src/objective-c/examples/Sample/Build/Build-%s' % where) text = 'Objective-C binary sizes\n'