Merge github.com:grpc/grpc into scalable-poll

pull/1608/head
Craig Tiller 10 years ago
commit 609fa1da4c
  1. 3
      BUILD
  2. 237
      Makefile
  3. 15
      build.json
  4. 65
      doc/connection-backoff.md
  5. 4
      include/grpc/support/port_platform.h
  6. 49
      include/grpc/support/subprocess.h
  7. 2
      include/grpc/support/tls.h
  8. 6
      include/grpc/support/tls_pthread.h
  9. 108
      src/core/support/subprocess_posix.c
  10. 45
      src/core/support/tls_pthread.c
  11. 1
      src/csharp/.gitignore
  12. 1
      src/csharp/EXPERIMENTAL-ONLY
  13. 26
      src/csharp/Grpc.Auth/Grpc.Auth.nuspec
  14. 4
      src/csharp/Grpc.Auth/Properties/AssemblyInfo.cs
  15. 2
      src/csharp/Grpc.Core.Tests/Properties/AssemblyInfo.cs
  16. 1
      src/csharp/Grpc.Core/.gitignore
  17. 12
      src/csharp/Grpc.Core/Grpc.Core.nuspec
  18. 2
      src/csharp/Grpc.Core/Properties/AssemblyInfo.cs
  19. 2
      src/csharp/Grpc.Examples.MathClient/Properties/AssemblyInfo.cs
  20. 4
      src/csharp/Grpc.Examples.MathServer/Grpc.Examples.MathServer.csproj
  21. 2
      src/csharp/Grpc.Examples.MathServer/Properties/AssemblyInfo.cs
  22. 2
      src/csharp/Grpc.Examples.Tests/Properties/AssemblyInfo.cs
  23. 2
      src/csharp/Grpc.Examples/Properties/AssemblyInfo.cs
  24. 2
      src/csharp/Grpc.IntegrationTesting.Client/Properties/AssemblyInfo.cs
  25. 2
      src/csharp/Grpc.IntegrationTesting.Server/Properties/AssemblyInfo.cs
  26. 2
      src/csharp/Grpc.IntegrationTesting/Properties/AssemblyInfo.cs
  27. 15
      src/csharp/Grpc.nuspec
  28. 111
      src/csharp/README.md
  29. 22
      src/csharp/build_packages.bat
  30. 18
      src/csharp/buildall.bat
  31. 14
      src/node/interop/interop_client.js
  32. 4
      src/node/test/interop_sanity_test.js
  33. 63
      src/objective-c/examples/Sample/SampleTests/RemoteProtoTests.m
  34. 17
      src/php/ext/grpc/call.c
  35. 4
      src/php/ext/grpc/call.h
  36. 50
      src/php/ext/grpc/completion_queue.c
  37. 50
      src/php/ext/grpc/completion_queue.h
  38. 2
      src/php/ext/grpc/config.m4
  39. 3
      src/php/ext/grpc/php_grpc.c
  40. 19
      src/php/ext/grpc/server.c
  41. 1
      src/php/ext/grpc/server.h
  42. 2
      templates/Makefile.template
  43. 1
      test/core/end2end/gen_build_json.py
  44. 7
      test/core/end2end/tests/request_response_with_trailing_metadata_and_payload.c
  45. 81
      test/core/fling/fling_test.c
  46. 66
      tools/dockerfile/grpc_java_android/Dockerfile
  47. 42
      tools/dockerfile/grpc_java_android/README.md
  48. 97
      tools/run_tests/tests.json
  49. 71
      vsprojects/Grpc.mak
  50. 5
      vsprojects/gpr/gpr.vcxproj
  51. 9
      vsprojects/gpr/gpr.vcxproj.filters
  52. 6
      vsprojects/nuget_package/README.md
  53. 1
      vsprojects/nuget_package/buildall.bat
  54. 4
      vsprojects/nuget_package/grpc.native.csharp_ext.nuspec

@ -74,6 +74,7 @@ cc_library(
"src/core/support/string.c",
"src/core/support/string_posix.c",
"src/core/support/string_win32.c",
"src/core/support/subprocess_posix.c",
"src/core/support/sync.c",
"src/core/support/sync_posix.c",
"src/core/support/sync_win32.c",
@ -83,6 +84,7 @@ cc_library(
"src/core/support/time.c",
"src/core/support/time_posix.c",
"src/core/support/time_win32.c",
"src/core/support/tls_pthread.c",
],
hdrs = [
"include/grpc/support/alloc.h",
@ -100,6 +102,7 @@ cc_library(
"include/grpc/support/port_platform.h",
"include/grpc/support/slice.h",
"include/grpc/support/slice_buffer.h",
"include/grpc/support/subprocess.h",
"include/grpc/support/sync.h",
"include/grpc/support/sync_generic.h",
"include/grpc/support/sync_posix.h",

File diff suppressed because one or more lines are too long

@ -315,6 +315,7 @@
"include/grpc/support/port_platform.h",
"include/grpc/support/slice.h",
"include/grpc/support/slice_buffer.h",
"include/grpc/support/subprocess.h",
"include/grpc/support/sync.h",
"include/grpc/support/sync_generic.h",
"include/grpc/support/sync_posix.h",
@ -362,6 +363,7 @@
"src/core/support/string.c",
"src/core/support/string_posix.c",
"src/core/support/string_win32.c",
"src/core/support/subprocess_posix.c",
"src/core/support/sync.c",
"src/core/support/sync_posix.c",
"src/core/support/sync_win32.c",
@ -370,7 +372,8 @@
"src/core/support/thd_win32.c",
"src/core/support/time.c",
"src/core/support/time_posix.c",
"src/core/support/time_win32.c"
"src/core/support/time_win32.c",
"src/core/support/tls_pthread.c"
],
"secure": "no",
"vs_project_guid": "{B23D3D1A-9438-4EDA-BEB6-9A0A03D17792}"
@ -2130,7 +2133,7 @@
},
{
"name": "qps_driver",
"build": "tool",
"build": "benchmark",
"language": "c++",
"src": [
"test/cpp/qps/qps_driver.cc"
@ -2148,8 +2151,7 @@
},
{
"name": "qps_test",
"build": "test",
"run": false,
"build": "benchmark",
"language": "c++",
"src": [
"test/cpp/qps/qps_test.cc"
@ -2161,12 +2163,13 @@
"grpc++",
"grpc",
"gpr_test_util",
"gpr"
"gpr",
"grpc++_test_config"
]
},
{
"name": "qps_worker",
"build": "tool",
"build": "benchmark",
"language": "c++",
"headers": [
"test/cpp/qps/client.h",

@ -0,0 +1,65 @@
GRPC Connection Backoff Protocol
================================
When we do a connection to a backend which fails, it is typically desirable to
not retry immediately (to avoid flooding the network or the server with
requests) and instead do some form of exponential backoff.
We have several parameters:
1. INITIAL_BACKOFF (how long to wait after the first failure before retrying)
2. MULTIPLIER (factor with which to multiply backoff after a failed retry)
3. MAX_BACKOFF (Upper bound on backoff)
4. MIN_CONNECTION_TIMEOUT
## Proposed Backoff Algorithm
Exponentially back off the start time of connection attempts up to a limit of
MAX_BACKOFF.
```
ConnectWithBackoff()
current_backoff = INITIAL_BACKOFF
current_deadline = now() + INITIAL_BACKOFF
while (TryConnect(Max(current_deadline, MIN_CONNECT_TIMEOUT))
!= SUCCESS)
SleepUntil(current_deadline)
current_backoff = Min(current_backoff * MULTIPLIER, MAX_BACKOFF)
current_deadline = now() + current_backoff
```
## Historical Algorithm in Stubby
Exponentially increase up to a limit of MAX_BACKOFF the intervals between
connection attempts. This is what stubby 2 uses, and is equivalent if
TryConnect() fails instantly.
```
LegacyConnectWithBackoff()
current_backoff = INITIAL_BACKOFF
while (TryConnect(MIN_CONNECT_TIMEOUT) != SUCCESS)
SleepFor(current_backoff)
current_backoff = Min(current_backoff * MULTIPLIER, MAX_BACKOFF)
```
The grpc C implementation currently uses this approach with an initial backoff
of 1 second, multiplier of 2, and maximum backoff of 120 seconds. (This will
change)
Stubby, or at least rpc2, uses exactly this algorithm with an initial backoff
of 1 second, multiplier of 1.2, and a maximum backoff of 120 seconds.
## Use Cases to Consider
* Client tries to connect to a server which is down for multiple hours, eg for
maintenance
* Client tries to connect to a server which is overloaded
* User is bringing up both a client and a server at the same time
* In particular, we would like to avoid a large unnecessary delay if the
client connects to a server which is about to come up
* Client/server are misconfigured such that connection attempts always fail
* We want to make sure these don’t put too much load on the server by
default.
* Server is overloaded and wants to transiently make clients back off
* Application has out of band reason to believe a server is back
* We should consider an out of band mechanism for the client to hint that
we should short circuit the backoff.

@ -77,6 +77,7 @@
#define GPR_POSIX_ENV 1
#define GPR_POSIX_FILE 1
#define GPR_POSIX_STRING 1
#define GPR_POSIX_SUBPROCESS 1
#define GPR_POSIX_SYNC 1
#define GPR_POSIX_TIME 1
#define GPR_GETPID_IN_UNISTD_H 1
@ -122,6 +123,7 @@
#endif
#define GPR_POSIX_FILE 1
#define GPR_POSIX_STRING 1
#define GPR_POSIX_SUBPROCESS 1
#define GPR_POSIX_SYNC 1
#define GPR_POSIX_TIME 1
#define GPR_GETPID_IN_UNISTD_H 1
@ -154,6 +156,7 @@
#define GPR_POSIX_ENV 1
#define GPR_POSIX_FILE 1
#define GPR_POSIX_STRING 1
#define GPR_POSIX_SUBPROCESS 1
#define GPR_POSIX_SYNC 1
#define GPR_POSIX_TIME 1
#define GPR_GETPID_IN_UNISTD_H 1
@ -180,6 +183,7 @@
#define GPR_POSIX_ENV 1
#define GPR_POSIX_FILE 1
#define GPR_POSIX_STRING 1
#define GPR_POSIX_SUBPROCESS 1
#define GPR_POSIX_SYNC 1
#define GPR_POSIX_TIME 1
#define GPR_GETPID_IN_UNISTD_H 1

@ -0,0 +1,49 @@
/*
*
* Copyright 2015, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef GRPC_SUPPORT_SUBPROCESS_H
#define GRPC_SUPPORT_SUBPROCESS_H
typedef struct gpr_subprocess gpr_subprocess;
/* .exe on windows, empty on unices */
char *gpr_subprocess_binary_extension();
gpr_subprocess *gpr_subprocess_create(int argc, char **argv);
/* if subprocess has not been joined, kill it */
void gpr_subprocess_destroy(gpr_subprocess *p);
/* returns exit status; can be called at most once */
int gpr_subprocess_join(gpr_subprocess *p);
void gpr_subprocess_interrupt(gpr_subprocess *p);
#endif

@ -54,7 +54,7 @@
Destroying a thread local:
gpr_tls_destroy(&foo);
Setting a thread local:
Setting a thread local (returns new_value):
gpr_tls_set(&foo, new_value);
Accessing a thread local:

@ -34,6 +34,9 @@
#ifndef GRPC_SUPPORT_TLS_PTHREAD_H
#define GRPC_SUPPORT_TLS_PTHREAD_H
#include <grpc/support/log.h> /* for GPR_ASSERT */
#include <pthread.h>
/* Thread local storage based on pthread library calls.
#include tls.h to use this - and see that file for documentation */
@ -46,8 +49,7 @@ struct gpr_pthread_thread_local {
#define gpr_tls_init(tls) GPR_ASSERT(0 == pthread_key_create(&(tls)->key, NULL))
#define gpr_tls_destroy(tls) pthread_key_delete((tls)->key)
#define gpr_tls_set(tls, new_value) \
GPR_ASSERT(pthread_setspecific((tls)->key, (void*)(new_value)) == 0)
gpr_intptr gpr_tls_set(struct gpr_pthread_thread_local *tls, gpr_intptr value);
#define gpr_tls_get(tls) ((gpr_intptr)pthread_getspecific((tls)->key))
#endif

@ -0,0 +1,108 @@
/*
*
* Copyright 2015, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <grpc/support/port_platform.h>
#ifdef GPR_POSIX_SUBPROCESS
#include <grpc/support/subprocess.h>
#include <unistd.h>
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
struct gpr_subprocess {
int pid;
int joined;
};
char *gpr_subprocess_binary_extension() { return ""; }
gpr_subprocess *gpr_subprocess_create(int argc, char **argv) {
gpr_subprocess *r;
int pid;
char **exec_args;
pid = fork();
if (pid == -1) {
return NULL;
} else if (pid == 0) {
exec_args = gpr_malloc((argc + 1) * sizeof(char *));
memcpy(exec_args, argv, argc * sizeof(char *));
exec_args[argc] = NULL;
execv(exec_args[0], exec_args);
/* if we reach here, an error has occurred */
gpr_log(GPR_ERROR, "execv '%s' failed: %s", exec_args[0], strerror(errno));
_exit(1);
return NULL;
} else {
r = gpr_malloc(sizeof(gpr_subprocess));
memset(r, 0, sizeof(*r));
r->pid = pid;
return r;
}
}
void gpr_subprocess_destroy(gpr_subprocess *p) {
if (!p->joined) {
kill(p->pid, SIGKILL);
gpr_subprocess_join(p);
}
gpr_free(p);
}
int gpr_subprocess_join(gpr_subprocess *p) {
int status;
if (waitpid(p->pid, &status, 0) == -1) {
gpr_log(GPR_ERROR, "waitpid failed: %s", strerror(errno));
return -1;
}
return status;
}
void gpr_subprocess_interrupt(gpr_subprocess *p) {
if (!p->joined) {
kill(p->pid, SIGINT);
}
}
#endif /* GPR_POSIX_SUBPROCESS */

@ -0,0 +1,45 @@
/*
*
* Copyright 2015, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <grpc/support/port_platform.h>
#ifdef GPR_PTHREAD_TLS
#include <grpc/support/tls.h>
gpr_intptr gpr_tls_set(struct gpr_pthread_thread_local *tls, gpr_intptr value) {
GPR_ASSERT(0 == pthread_setspecific(tls->key, (void*)value));
return value;
}
#endif /* GPR_PTHREAD_TLS */

@ -5,3 +5,4 @@ test-results
packages
Grpc.v12.suo
TestResult.xml
*.nupkg

@ -1 +0,0 @@
gRPC C# is work-in-progress and is not intended to be used. See README.

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<package>
<metadata>
<id>Grpc.Auth</id>
<title>gRPC C# Auth</title>
<summary>Auth library for C# implementation of gRPC - an RPC library and framework</summary>
<description>Auth library for C# implementation of gRPC - an RPC library and framework. See project site for more info.</description>
<version>0.5.0</version>
<authors>Google Inc.</authors>
<owners>jtattermusch</owners>
<licenseUrl>https://github.com/grpc/grpc/blob/master/LICENSE</licenseUrl>
<projectUrl>https://github.com/grpc/grpc</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<releaseNotes>Release 0.5.0 of gRPC C#</releaseNotes>
<copyright>Copyright 2015, Google Inc.</copyright>
<tags>gRPC RPC Protocol HTTP/2 Auth OAuth2</tags>
<dependencies>
<dependency id="BouncyCastle" version="1.7.0" />
<dependency id="Google.Apis.Auth" version="1.9.1" />
<dependency id="Grpc.Core" version="0.5.0" />
</dependencies>
</metadata>
<files>
<file src="bin/Release/Grpc.Auth.dll" target="lib/net45" />
</files>
</package>

@ -9,6 +9,6 @@ using System.Runtime.CompilerServices;
[assembly: AssemblyCopyright("Google Inc. All rights reserved.")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("0.2.*")]
[assembly: AssemblyVersion("0.5.*")]
[assembly: InternalsVisibleTo("Grpc.Auth.Tests")]
[assembly: InternalsVisibleTo("Grpc.Auth.Tests")]

@ -9,4 +9,4 @@ using System.Runtime.CompilerServices;
[assembly: AssemblyCopyright("Google Inc. All rights reserved.")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("0.2.*")]
[assembly: AssemblyVersion("0.5.*")]

@ -1,3 +1,2 @@
bin
obj
*.nupkg

@ -2,23 +2,21 @@
<package>
<metadata>
<id>Grpc.Core</id>
<title>gRPC Core</title>
<title>gRPC C# Core</title>
<summary>Core C# implementation of gRPC - an RPC library and framework</summary>
<description>Core C# implementation of gRPC - an RPC library and framework. See project site for more info.
This is an experimental release, not ready to use.
</description>
<version>0.2.1</version>
<description>Core C# implementation of gRPC - an RPC library and framework. See project site for more info.</description>
<version>0.5.0</version>
<authors>Google Inc.</authors>
<owners>jtattermusch</owners>
<licenseUrl>https://github.com/grpc/grpc/blob/master/LICENSE</licenseUrl>
<projectUrl>https://github.com/grpc/grpc</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<releaseNotes>The first experimental release. Not ready to use.</releaseNotes>
<releaseNotes>Release 0.5.0 of gRPC C#</releaseNotes>
<copyright>Copyright 2015, Google Inc.</copyright>
<tags>gRPC RPC Protocol HTTP/2</tags>
<dependencies>
<dependency id="Microsoft.Bcl.Immutable" version="1.0.34" />
<dependency id="grpc.native.csharp_ext" version="0.6.0.0" />
<dependency id="grpc.native.csharp_ext" version="0.8.0.0" />
</dependencies>
</metadata>
<files>

@ -9,6 +9,6 @@ using System.Runtime.CompilerServices;
[assembly: AssemblyCopyright("Google Inc. All rights reserved.")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("0.2.*")]
[assembly: AssemblyVersion("0.5.*")]
[assembly: InternalsVisibleTo("Grpc.Core.Tests")]

@ -9,4 +9,4 @@ using System.Runtime.CompilerServices;
[assembly: AssemblyCopyright("Google Inc. All rights reserved.")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("0.2.*")]
[assembly: AssemblyVersion("0.5.*")]

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@ -8,7 +8,7 @@
<ProjectGuid>{BF62FE08-373A-43D6-9D73-41CAA38B7011}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>Grpc.Examples.MathServer</RootNamespace>
<AssemblyName>Grpc.Examples.MathServer</AssemblyName>
<AssemblyName>MathServer</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">

@ -9,4 +9,4 @@ using System.Runtime.CompilerServices;
[assembly: AssemblyCopyright("Google Inc. All rights reserved.")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("0.1.*")]
[assembly: AssemblyVersion("0.5.*")]

@ -9,4 +9,4 @@ using System.Runtime.CompilerServices;
[assembly: AssemblyCopyright("Google Inc. All rights reserved.")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("0.2.*")]
[assembly: AssemblyVersion("0.5.*")]

@ -9,4 +9,4 @@ using System.Runtime.CompilerServices;
[assembly: AssemblyCopyright("Google Inc. All rights reserved.")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("0.2.*")]
[assembly: AssemblyVersion("0.5.*")]

@ -9,4 +9,4 @@ using System.Runtime.CompilerServices;
[assembly: AssemblyCopyright("Google Inc. All rights reserved.")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("0.2.*")]
[assembly: AssemblyVersion("0.5.*")]

@ -9,4 +9,4 @@ using System.Runtime.CompilerServices;
[assembly: AssemblyCopyright("Google Inc. All rights reserved.")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("0.2.*")]
[assembly: AssemblyVersion("0.5.*")]

@ -9,4 +9,4 @@ using System.Runtime.CompilerServices;
[assembly: AssemblyCopyright("Google Inc. All rights reserved.")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("0.2.*")]
[assembly: AssemblyVersion("0.5.*")]

@ -1,23 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<package >
<package>
<metadata>
<id>Grpc</id>
<title>gRPC</title>
<title>gRPC C#</title>
<summary>C# implementation of gRPC - an RPC library and framework</summary>
<description>C# implementation of gRPC - an RPC library and framework. See project site for more info.
This is an experimental release, not ready to use.
</description>
<version>0.2.0</version>
<description>C# implementation of gRPC - an RPC library and framework. See project site for more info.</description>
<version>0.5.0</version>
<authors>Google Inc.</authors>
<owners>jtattermusch</owners>
<licenseUrl>https://github.com/grpc/grpc/blob/master/LICENSE</licenseUrl>
<projectUrl>https://github.com/grpc/grpc</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<releaseNotes>The first experimental release. Not ready to use.</releaseNotes>
<releaseNotes>Release 0.5.0 of gRPC C#</releaseNotes>
<copyright>Copyright 2015, Google Inc.</copyright>
<tags>gRPC RPC Protocol HTTP/2</tags>
<dependencies>
<dependency id="Grpc.Core" version="0.2.0" />
<dependency id="Grpc.Core" version="0.5.0" />
</dependencies>
</metadata>
<files/>
</package>

@ -4,74 +4,117 @@ gRPC C#
A C# implementation of gRPC.
Status
-----------------
------
**This gRPC C# implementation is work-in-progress and is not expected to work yet.**
Ready for early adopters.
- The implementation is a wrapper around gRPC C core library
- Code only runs under mono currently, building gRPC C core library under Windows
is in progress.
- It is very possible that some parts of the code will be heavily refactored or
completely rewritten.
Usage: Windows
--------------
- Prerequisites: .NET Framework 4.5+, Visual Studio 2013 with NuGet extension installed (VS2015 should work).
INSTALLATION AND USAGE: WINDOWS
-------------------------------
- Open Visual Studio and start a new project/solution.
- Open Grpc.sln using Visual Studio 2013. NuGet dependencies will be restored
upon build.
- Add NuGet package `Grpc` as a dependency (Project options -> Manage NuGet Packages).
That will also pull all the transitive dependencies (including the native libraries that
gRPC C# is internally using).
- TODO: link to Helloworld example
INSTALLATION AND USAGE: LINUX & MONO
------------------------------------
Usage: Linux (Mono)
--------------
- Compile and install the gRPC C# extension library (that will be used via
P/Invoke from C#).
- Prerequisites: Mono framework, MonoDevelop 5.9 with NuGet add-in installed.
- Install gRPC C Core using instructions in https://github.com/grpc/homebrew-grpc
- TODO: explain using LD_LIBRARY_PATH or installation to /usr/local
- Open MonoDevelop and start a new project/solution.
- Add NuGet package `Grpc` as a dependency (Project -> Add NuGet packages).
- TODO: link to Helloworld example
Building: Windows
-----------------
You only need to go through these steps if you are planning to develop gRPC C#.
If you are a user of gRPC C#, go to Usage section above.
- Prerequisites for development: NET Framework 4.5+, Visual Studio 2013 (with NuGet and NUnit extensions installed).
- The grpc_csharp_ext native library needs to be built so you can build the Grpc C# solution. You can
either build the native solution in `vsprojects/grpc.sln` from Visual Studio manually, or you can use
a convenience batch script that builds everything for you.
```
make grpc_csharp_ext
sudo make install_grpc_csharp_ext
buildall.bat
```
- Prerequisites for development: Mono framework, MonoDevelop (IDE)
- Open Grpc.sln using Visual Studio 2013. NuGet dependencies will be restored
upon build (you need to have NuGet add-in installed).
Building: Linux & Mono
----------------------
You only need to go through these steps if you are planning to develop gRPC C#.
If you are a user of gRPC C#, go to Usage section above.
- Prerequisites for development: Mono framework, MonoDevelop 5.9 with NuGet and Nunit add-ins installed.
```
sudo apt-get install mono-devel
sudo apt-get install monodevelop monodevelop-nunit
sudo apt-get install nunit nunit-console
```
- NuGet is used to manage project's dependencies. Prior opening Grpc.sln,
download dependencies using NuGet restore command:
You can use older versions of MonoDevelop, but then you might need to restore
NuGet dependencies manually (by `nuget restore`), because older versions of MonoDevelop
don't support NuGet add-in.
- Compile and install the gRPC C# extension library (that will be used via
P/Invoke from C#).
```
# Import needed certicates into Mono certificate store:
mozroots --import --sync
# Download NuGet.exe http://nuget.codeplex.com/releases/
# Restore the nuget packages with Grpc C# dependencies
mono ~/Downloads/NuGet.exe restore Grpc.sln
make grpc_csharp_ext
sudo make install_grpc_csharp_ext
```
- Use MonoDevelop to open the solution Grpc.sln (you can also run unit tests
from there).
- Use MonoDevelop to open the solution Grpc.sln
- Build the solution & run all the tests from test view.
Tests
-----
- After building the solution with MonoDevelop, you can use
nunit-console to run the unit tests (currently only running one by
one will make them pass.
gRPC C# is using NUnit as the testing framework.
Under Visual Studio, make sure NUnit test adapter is installed (under "Extensions and Updates").
Then you should be able to run all the tests using Test Explorer.
Under Monodevelop, make sure you installed "NUnit support" in Add-in manager.
Then you should be able to run all the test from the Test View.
After building the solution, you can also run the tests from command line
using nunit-console tool.
```
# from Grpc.Core.Test/bin/Debug directory
nunit-console Grpc.Core.Tests.dll
```
CONTENTS
Contents
--------
- ext:
The extension library that wraps C API to be more digestible by C#.
- Grpc.Auth:
gRPC OAuth2 support.
- Grpc.Core:
The main gRPC C# library.
- Grpc.Examples:
API examples for math.proto
- Grpc.Examples.MathClient:
An example client that sends some requests to math server.
- Grpc.Examples.MathServer:
An example client that sends some requests to math server.
- Grpc.IntegrationTesting:
Client for cross-language gRPC implementation testing (interop testing).
Cross-language gRPC implementation testing (interop testing).

@ -0,0 +1,22 @@
@rem Builds gRPC NuGet packages
@rem Adjust the location of nuget.exe
set NUGET=C:\nuget\nuget.exe
setlocal
cd ..\..\vsprojects\nuget_package
@call buildall.bat || goto :error
endlocal
@call buildall.bat || goto :error
%NUGET% pack ..\..\vsprojects\nuget_package\grpc.native.csharp_ext.nuspec || goto :error
%NUGET% pack Grpc.Core\Grpc.Core.nuspec || goto :error
%NUGET% pack Grpc.Auth\Grpc.Auth.nuspec || goto :error
%NUGET% pack Grpc.nuspec || goto :error
goto :EOF
:error
echo Failed!
exit /b %errorlevel%

@ -0,0 +1,18 @@
@rem Convenience script to build gRPC C# from command line
setlocal
@rem Set VS variables (uses Visual Studio 2013)
@call "%VS120COMNTOOLS%\..\..\vc\vcvarsall.bat" x86
@rem Build the C# native extension
msbuild ..\..\vsprojects\grpc.sln /t:grpc_csharp_ext || goto :error
msbuild Grpc.sln /p:Configuration=Debug || goto :error
msbuild Grpc.sln /p:Configuration=Release || goto :error
endlocal
goto :EOF
:error
echo Failed!
exit /b %errorlevel%

@ -263,6 +263,19 @@ function cancelAfterFirstResponse(client, done) {
});
}
function timeoutOnSleepingServer(client, done) {
var deadline = new Date();
deadline.setMilliseconds(deadline.getMilliseconds() + 1);
var call = client.fullDuplexCall(null, deadline);
call.write({
payload: {body: zeroBuffer(27182)}
});
call.on('error', function(error) {
assert.strictEqual(error.code, grpc.status.DEADLINE_EXCEEDED);
done();
});
}
/**
* Run one of the authentication tests.
* @param {string} expected_user The expected username in the response
@ -315,6 +328,7 @@ var test_cases = {
empty_stream: emptyStream,
cancel_after_begin: cancelAfterBegin,
cancel_after_first_response: cancelAfterFirstResponse,
timeout_on_sleeping_server: timeoutOnSleepingServer,
compute_engine_creds: _.partial(authTest, COMPUTE_ENGINE_USER, null),
service_account_creds: _.partial(authTest, AUTH_USER, AUTH_SCOPE),
jwt_token_creds: _.partial(authTest, AUTH_USER, null)

@ -86,4 +86,8 @@ describe('Interop tests', function() {
interop_client.runTest(port, name_override, 'cancel_after_first_response',
true, true, done);
});
it('should pass timeout_on_sleeping_server', function(done) {
interop_client.runTest(port, name_override, 'timeout_on_sleeping_server',
true, true, done);
});
});

@ -31,9 +31,12 @@
*
*/
#include <grpc/status.h>
#import <UIKit/UIKit.h>
#import <XCTest/XCTest.h>
#import <gRPC/ProtoRPC.h>
#import <gRPC/GRXWriter+Immediate.h>
#import <RemoteTest/Messages.pb.h>
#import <RemoteTest/Test.pb.h>
@ -69,7 +72,7 @@
}
- (void)testLargeUnaryRPC {
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"EmptyUnary"];
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"LargeUnary"];
RMTSimpleRequest *request = [[[[[[RMTSimpleRequestBuilder alloc] init]
setResponseType:RMTPayloadTypeCompressable]
@ -95,7 +98,7 @@
}
- (void)testClientStreamingRPC {
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"EmptyUnary"];
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"ClientStreaming"];
id request1 = [[[[RMTStreamingInputCallRequestBuilder alloc] init]
setPayloadBuilder:[[[RMTPayloadBuilder alloc] init]
@ -130,4 +133,60 @@
[self waitForExpectationsWithTimeout:4. handler:nil];
}
- (void)testServerStreamingRPC {
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"ServerStreaming"];
NSArray *expectedSizes = @[@31415, @9, @2653, @58979];
__block int index = 0;
id request = [[[[[[[RMTStreamingOutputCallRequestBuilder alloc] init]
addResponseParameters:[[[[RMTResponseParametersBuilder alloc] init]
setSize:31415] build]]
addResponseParameters:[[[[RMTResponseParametersBuilder alloc] init]
setSize:9] build]]
addResponseParameters:[[[[RMTResponseParametersBuilder alloc] init]
setSize:2653] build]]
addResponseParameters:[[[[RMTResponseParametersBuilder alloc] init]
setSize:58979] build]]
build];
[_service streamingOutputCallWithRequest:request handler:^(BOOL done, RMTStreamingOutputCallResponse *response, NSError *error){
XCTAssertNil(error, @"Finished with unexpected error: %@", error);
id expectedResponseBuilder = [[RMTStreamingOutputCallResponseBuilder alloc] init];
id expectedPayload = [[[[[RMTPayloadBuilder alloc] init]
setType:RMTPayloadTypeCompressable]
setBody:[NSMutableData dataWithLength:[expectedSizes[index] unsignedIntegerValue]]]
build];
expectedResponseBuilder = [expectedResponseBuilder setPayload:expectedPayload];
id expectedResponse = [expectedResponseBuilder build];
XCTAssertEqualObjects(response, expectedResponse);
[expectation fulfill];
index += 1;
}];
[self waitForExpectationsWithTimeout:4 handler:nil];
}
- (void)testEmptyStreamRPC {
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"EmptyStream"];
[_service fullDuplexCallWithRequestsWriter:[GRXWriter emptyWriter]
handler:^(bool done, RMTStreamingOutputCallResponse *response, NSError *error) {
XCTAssertNil(error, @"Finished with unexpected error: %@", error);
XCTAssert(done, @"Unexpected response: %@", response);
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:4 handler:nil];
}
- (void)testCancelAfterBeginRPC {
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"CancelAfterBegin"];
// TODO(mlumish): change to writing that blocks instead of writing
ProtoRPC *call = [_service RPCToStreamingInputCallWithRequestsWriter:[GRXWriter emptyWriter]
handler:^(RMTStreamingInputCallResponse *response, NSError *error) {
XCTAssertEqual([error code], GRPC_STATUS_CANCELLED);
[expectation fulfill];
}];
[call start];
[call cancel];
[self waitForExpectationsWithTimeout:1 handler:nil];
}
@end

@ -52,6 +52,7 @@
#include <grpc/support/alloc.h>
#include <grpc/grpc.h>
#include "completion_queue.h"
#include "timeval.h"
#include "channel.h"
#include "byte_buffer.h"
@ -62,13 +63,6 @@ zend_class_entry *grpc_ce_call;
void free_wrapped_grpc_call(void *object TSRMLS_DC) {
wrapped_grpc_call *call = (wrapped_grpc_call *)object;
if (call->owned && call->wrapped != NULL) {
if (call->queue != NULL) {
grpc_completion_queue_shutdown(call->queue);
while (grpc_completion_queue_next(call->queue, gpr_inf_future).type !=
GRPC_QUEUE_SHUTDOWN)
;
grpc_completion_queue_destroy(call->queue);
}
grpc_call_destroy(call->wrapped);
}
efree(call);
@ -95,15 +89,13 @@ zend_object_value create_wrapped_grpc_call(zend_class_entry *class_type
/* Wraps a grpc_call struct in a PHP object. Owned indicates whether the struct
should be destroyed at the end of the object's lifecycle */
zval *grpc_php_wrap_call(grpc_call *wrapped, grpc_completion_queue *queue,
bool owned) {
zval *grpc_php_wrap_call(grpc_call *wrapped, bool owned) {
zval *call_object;
MAKE_STD_ZVAL(call_object);
object_init_ex(call_object, grpc_ce_call);
wrapped_grpc_call *call =
(wrapped_grpc_call *)zend_object_store_get_object(call_object TSRMLS_CC);
call->wrapped = wrapped;
call->queue = queue;
return call_object;
}
@ -247,9 +239,8 @@ PHP_METHOD(Call, __construct) {
wrapped_grpc_timeval *deadline =
(wrapped_grpc_timeval *)zend_object_store_get_object(
deadline_obj TSRMLS_CC);
call->queue = grpc_completion_queue_create();
call->wrapped = grpc_channel_create_call(
channel->wrapped, call->queue, method, channel->target,
channel->wrapped, completion_queue, method, channel->target,
deadline->wrapped);
}
@ -415,7 +406,7 @@ PHP_METHOD(Call, startBatch) {
(long)error TSRMLS_CC);
goto cleanup;
}
event = grpc_completion_queue_pluck(call->queue, call->wrapped,
event = grpc_completion_queue_pluck(completion_queue, call->wrapped,
gpr_inf_future);
if (!event.success) {
zend_throw_exception(spl_ce_LogicException,

@ -54,15 +54,13 @@ typedef struct wrapped_grpc_call {
bool owned;
grpc_call *wrapped;
grpc_completion_queue *queue;
} wrapped_grpc_call;
/* Initializes the Call PHP class */
void grpc_init_call(TSRMLS_D);
/* Creates a Call object that wraps the given grpc_call struct */
zval *grpc_php_wrap_call(grpc_call *wrapped, grpc_completion_queue *queue,
bool owned);
zval *grpc_php_wrap_call(grpc_call *wrapped, bool owned);
/* Creates and returns a PHP associative array of metadata from a C array of
* call metadata */

@ -0,0 +1,50 @@
/*
*
* Copyright 2015, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "completion_queue.h"
#include <php.h>
grpc_completion_queue *completion_queue;
void grpc_php_init_completion_queue(TSRMLS_D) {
completion_queue = grpc_completion_queue_create();
}
void grpc_php_shutdown_completion_queue(TSRMLS_D) {
grpc_completion_queue_shutdown(completion_queue);
while (grpc_completion_queue_next(completion_queue, gpr_inf_future).type !=
GRPC_QUEUE_SHUTDOWN)
;
grpc_completion_queue_destroy(completion_queue);
}

@ -0,0 +1,50 @@
/*
*
* Copyright 2015, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef GRPC_PHP_GRPC_COMPLETION_QUEUE_H_
#define GRPC_PHP_GRPC_COMPLETION_QUEUE_H_
#include <php.h>
#include <grpc/grpc.h>
/* The global completion queue for all operations */
extern grpc_completion_queue *completion_queue;
/* Initializes the completion queue */
void grpc_php_init_completion_queue(TSRMLS_D);
/* Shut down the completion queue */
void grpc_php_shutdown_completion_queue(TSRMLS_D);
#endif /* GRPC_PHP_GRPC_COMPLETION_QUEUE_H_ */

@ -66,5 +66,5 @@ if test "$PHP_GRPC" != "no"; then
PHP_SUBST(GRPC_SHARED_LIBADD)
PHP_NEW_EXTENSION(grpc, byte_buffer.c call.c channel.c credentials.c timeval.c server.c server_credentials.c php_grpc.c, $ext_shared, , -Wall -Werror -std=c11)
PHP_NEW_EXTENSION(grpc, byte_buffer.c call.c channel.c completion_queue.c credentials.c timeval.c server.c server_credentials.c php_grpc.c, $ext_shared, , -Wall -Werror -std=c11)
fi

@ -37,6 +37,7 @@
#include "timeval.h"
#include "credentials.h"
#include "server_credentials.h"
#include "completion_queue.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
@ -188,6 +189,7 @@ PHP_MINIT_FUNCTION(grpc) {
grpc_init_timeval(TSRMLS_C);
grpc_init_credentials(TSRMLS_C);
grpc_init_server_credentials(TSRMLS_C);
grpc_php_init_completion_queue(TSRMLS_C);
return SUCCESS;
}
/* }}} */
@ -199,6 +201,7 @@ PHP_MSHUTDOWN_FUNCTION(grpc) {
UNREGISTER_INI_ENTRIES();
*/
grpc_shutdown_timeval(TSRMLS_C);
grpc_php_shutdown_completion_queue(TSRMLS_C);
grpc_shutdown();
return SUCCESS;
}

@ -51,6 +51,7 @@
#include <grpc/support/log.h>
#include <grpc/grpc_security.h>
#include "completion_queue.h"
#include "server.h"
#include "channel.h"
#include "server_credentials.h"
@ -61,13 +62,6 @@ zend_class_entry *grpc_ce_server;
/* Frees and destroys an instance of wrapped_grpc_server */
void free_wrapped_grpc_server(void *object TSRMLS_DC) {
wrapped_grpc_server *server = (wrapped_grpc_server *)object;
if (server->queue != NULL) {
grpc_completion_queue_shutdown(server->queue);
while (grpc_completion_queue_next(server->queue, gpr_inf_future).type !=
GRPC_QUEUE_SHUTDOWN)
;
grpc_completion_queue_destroy(server->queue);
}
if (server->wrapped != NULL) {
grpc_server_shutdown(server->wrapped);
grpc_server_destroy(server->wrapped);
@ -96,7 +90,6 @@ zend_object_value create_wrapped_grpc_server(zend_class_entry *class_type
/**
* Constructs a new instance of the Server class
* @param CompletionQueue $queue The completion queue to use with the server
* @param array $args The arguments to pass to the server (optional)
*/
PHP_METHOD(Server, __construct) {
@ -112,7 +105,6 @@ PHP_METHOD(Server, __construct) {
1 TSRMLS_CC);
return;
}
server->queue = grpc_completion_queue_create();
if (args_array == NULL) {
server->wrapped = grpc_server_create(NULL);
} else {
@ -120,7 +112,7 @@ PHP_METHOD(Server, __construct) {
server->wrapped = grpc_server_create(&args);
efree(args.args);
}
grpc_server_register_completion_queue(server->wrapped, server->queue);
grpc_server_register_completion_queue(server->wrapped, completion_queue);
}
/**
@ -144,21 +136,20 @@ PHP_METHOD(Server, requestCall) {
grpc_metadata_array_init(&metadata);
error_code =
grpc_server_request_call(server->wrapped, &call, &details, &metadata,
server->queue, server->queue, NULL);
completion_queue, completion_queue, NULL);
if (error_code != GRPC_CALL_OK) {
zend_throw_exception(spl_ce_LogicException, "request_call failed",
(long)error_code TSRMLS_CC);
goto cleanup;
}
event = grpc_completion_queue_pluck(server->queue, NULL, gpr_inf_future);
event = grpc_completion_queue_pluck(completion_queue, NULL, gpr_inf_future);
if (!event.success) {
zend_throw_exception(spl_ce_LogicException,
"Failed to request a call for some reason",
1 TSRMLS_CC);
goto cleanup;
}
add_property_zval(result, "call", grpc_php_wrap_call(call, server->queue,
true));
add_property_zval(result, "call", grpc_php_wrap_call(call, true));
add_property_string(result, "method", details.method, true);
add_property_string(result, "host", details.host, true);
add_property_zval(result, "absolute_deadline",

@ -53,7 +53,6 @@ typedef struct wrapped_grpc_server {
zend_object std;
grpc_server *wrapped;
grpc_completion_queue *queue;
} wrapped_grpc_server;
/* Initializes the Server class */

@ -1369,6 +1369,8 @@ $(${tgt.name.upper()}_OBJS)\
% endif
% if tgt.language == 'c++' and tgt.build == 'test':
$(GTEST_LIB)\
% elif tgt.language == 'c++' and tgt.build == 'benchmark':
$(GTEST_LIB)\
% endif
-o $(BINDIR)/$(CONFIG)/${tgt.name}
% if tgt.build == 'protoc' or tgt.language == 'c++':

@ -75,6 +75,7 @@ END2END_TESTS = {
'ping_pong_streaming': default_test_options,
'registered_call': default_test_options,
'request_response_with_binary_metadata_and_payload': default_test_options,
'request_response_with_trailing_metadata_and_payload': default_test_options,
'request_response_with_metadata_and_payload': default_test_options,
'request_response_with_payload': default_test_options,
'request_response_with_payload_and_call_creds': TestOptions(flaky=False, secure=True),

@ -164,14 +164,9 @@ static void test_request_response_with_metadata_and_payload(
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(f.server, &s,
&call_details,
&request_metadata_recv,
<<<<<<< HEAD
f.server_cq, tag(101)));
cq_expect_completion(v_server, tag(101), 1);
=======
f.server_cq, f.server_cq,
tag(101)));
cq_expect_completion(v_server, tag(101), GRPC_OP_OK);
>>>>>>> a468c36601dd5997580129bbd66b5ebed02521f8
cq_expect_completion(v_server, tag(101), 1);
cq_verify(v_server);
op = ops;

@ -31,20 +31,11 @@
*
*/
#ifndef _POSIX_SOURCE
#define _POSIX_SOURCE
#endif
#include <unistd.h>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <stdio.h>
#include <grpc/support/alloc.h>
#include <grpc/support/subprocess.h>
#include <grpc/support/host_port.h>
#include "src/core/support/string.h"
#include "test/core/util/port.h"
@ -56,10 +47,7 @@ int main(int argc, char **argv) {
int port = grpc_pick_unused_port_or_die();
char *args[10];
int status;
pid_t svr, cli;
/* seed rng with pid, so we don't end up with the same random numbers as a
concurrently running test binary */
srand(getpid());
gpr_subprocess *svr, *cli;
/* figure out where we are */
if (lslash) {
memcpy(root, me, lslash - me);
@ -68,45 +56,36 @@ int main(int argc, char **argv) {
strcpy(root, ".");
}
/* start the server */
svr = fork();
if (svr == 0) {
gpr_asprintf(&args[0], "%s/fling_server", root);
args[1] = "--bind";
gpr_join_host_port(&args[2], "::", port);
args[3] = "--no-secure";
args[4] = 0;
execv(args[0], args);
gpr_asprintf(&args[0], "%s/fling_server%s", root, gpr_subprocess_binary_extension());
args[1] = "--bind";
gpr_join_host_port(&args[2], "::", port);
args[3] = "--no-secure";
svr = gpr_subprocess_create(4, args);
gpr_free(args[0]);
gpr_free(args[2]);
gpr_free(args[0]);
gpr_free(args[2]);
return 1;
}
/* wait a little */
sleep(2);
/* start the client */
cli = fork();
if (cli == 0) {
gpr_asprintf(&args[0], "%s/fling_client", root);
args[1] = "--target";
gpr_join_host_port(&args[2], "127.0.0.1", port);
args[3] = "--scenario=ping-pong-request";
args[4] = "--no-secure";
args[5] = 0;
execv(args[0], args);
gpr_asprintf(&args[0], "%s/fling_client%s", root, gpr_subprocess_binary_extension());
args[1] = "--target";
gpr_join_host_port(&args[2], "127.0.0.1", port);
args[3] = "--scenario=ping-pong-request";
args[4] = "--no-secure";
args[5] = 0;
cli = gpr_subprocess_create(6, args);
gpr_free(args[0]);
gpr_free(args[2]);
gpr_free(args[0]);
gpr_free(args[2]);
return 1;
}
/* wait for completion */
printf("waiting for client\n");
if (waitpid(cli, &status, 0) == -1) return 2;
if (!WIFEXITED(status)) return 4;
if (WEXITSTATUS(status)) return WEXITSTATUS(status);
printf("waiting for server\n");
kill(svr, SIGINT);
if (waitpid(svr, &status, 0) == -1) return 2;
if (!WIFEXITED(status)) return 4;
if (WEXITSTATUS(status)) return WEXITSTATUS(status);
return 0;
if ((status = gpr_subprocess_join(cli))) {
gpr_subprocess_destroy(cli);
gpr_subprocess_destroy(svr);
return status;
}
gpr_subprocess_destroy(cli);
gpr_subprocess_interrupt(svr);
status = gpr_subprocess_join(svr);
gpr_subprocess_destroy(svr);
return status;
}

@ -0,0 +1,66 @@
# Copyright 2015, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# Dockerfile for the gRPC Java dev image
FROM grpc/java_base
# Required by accessing Android's aapt
RUN apt-get install -y lib32stdc++6 lib32z1 && apt-get clean
# Install Android SDK 24.2
RUN curl -L http://dl.google.com/android/android-sdk_r24.2-linux.tgz | tar xz -C /usr/local
# Environment variables
ENV ANDROID_HOME /usr/local/android-sdk-linux
ENV PATH $PATH:$ANDROID_HOME/tools
ENV PATH $PATH:$ANDROID_HOME/platform-tools
# Some old Docker versions consider '/' as HOME
ENV HOME /root
# Update sdk for android 5.1 (API level 22)
RUN echo y | android update sdk --all --filter platform-tools,build-tools-22.0.1,sys-img-armeabi-v7a-android-22,android-22,extra-android-m2repository,extra-google-m2repository --no-ui --force
# Create an AVD with API level 22
RUN echo no | android create avd --force -n avd-api-22 -t android-22
# Pull gRPC Java and trigger download of needed Maven and Gradle artifacts.
RUN git clone --depth 1 https://github.com/grpc/grpc-java.git /var/local/git/grpc-java && \
cd /var/local/git/grpc-java && \
./gradlew grpc-core:install grpc-stub:install grpc-okhttp:install grpc-protobuf-nano:install && \
rm -r "$(pwd)"
# Pull gRPC Android integration test App
RUN git clone --depth 1 https://github.com/madongfly/grpc-android-test.git /var/local/git/grpc-android-test
# Config android sdk for gradle
RUN cd /var/local/git/grpc-android-test && echo "sdk.dir=/usr/local/android-sdk-linux" > local.properties
# Build apks to trigger download of needed Maven and Gradle artifacts.
RUN cd /var/local/git/grpc-android-test && ./gradlew assembleDebug
RUN cd /var/local/git/grpc-android-test && ./gradlew assembleDebugAndroidTest

@ -0,0 +1,42 @@
GRPC Android Dockerfile
====================
Dockerfile for creating the gRPC Android integration test image
As of 2015/05 this
- is based on the gRPC Java base
- installs Android sdk 24.2
- creates an AVD for API level 22
- Pulls gRpc Android test App from github
Usage
-----
Start the emulator in a detached container, the argument is the name of the AVD you want to start:
```
$ sudo docker run --name=grpc_android_test -d grpc/android /var/local/git/grpc-android-test/start-emulator.sh avd-api-22
```
You can use the following cammand to wait until the emulator is ready:
```
$ sudo docker exec grpc_android_test /var/local/git/grpc-android-test/wait-for-emulator.sh
```
When you want to update the apk, run:
```
$ sudo docker exec grpc_android_test /var/local/git/grpc-android-test/update-apk.sh
```
It will pull the fresh code of gRpc Java and our integration test app from github, build and install it to the runing emulator (so you need to make sure there is a runing emulator).
Trigger the integration test:
```
$ sudo docker exec grpc_android_test /var/local/git/grpc-android-test/run-test.sh -e server_host <hostname or ip address> -e server_port 8030 -e server_host_override foo.test.google.fr -e use_tls true -e use_test_ca true
```
You can also use the android/adb cammands to get more info, such as:
```
$ sudo docker exec grpc_android_test android list avd
$ sudo docker exec grpc_android_test adb devices
$ sudo docker exec grpc_android_test adb logcat
```

@ -893,6 +893,15 @@
"posix"
]
},
{
"flaky": false,
"language": "c",
"name": "chttp2_fake_security_request_response_with_trailing_metadata_and_payload_test",
"platforms": [
"windows",
"posix"
]
},
{
"flaky": false,
"language": "c",
@ -1136,6 +1145,15 @@
"posix"
]
},
{
"flaky": false,
"language": "c",
"name": "chttp2_fullstack_request_response_with_trailing_metadata_and_payload_test",
"platforms": [
"windows",
"posix"
]
},
{
"flaky": false,
"language": "c",
@ -1357,6 +1375,14 @@
"posix"
]
},
{
"flaky": false,
"language": "c",
"name": "chttp2_fullstack_uds_posix_request_response_with_trailing_metadata_and_payload_test",
"platforms": [
"posix"
]
},
{
"flaky": false,
"language": "c",
@ -1595,6 +1621,15 @@
"posix"
]
},
{
"flaky": false,
"language": "c",
"name": "chttp2_simple_ssl_fullstack_request_response_with_trailing_metadata_and_payload_test",
"platforms": [
"windows",
"posix"
]
},
{
"flaky": false,
"language": "c",
@ -1838,6 +1873,15 @@
"posix"
]
},
{
"flaky": false,
"language": "c",
"name": "chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_trailing_metadata_and_payload_test",
"platforms": [
"windows",
"posix"
]
},
{
"flaky": false,
"language": "c",
@ -2081,6 +2125,15 @@
"posix"
]
},
{
"flaky": false,
"language": "c",
"name": "chttp2_socket_pair_request_response_with_trailing_metadata_and_payload_test",
"platforms": [
"windows",
"posix"
]
},
{
"flaky": false,
"language": "c",
@ -2324,6 +2377,15 @@
"posix"
]
},
{
"flaky": false,
"language": "c",
"name": "chttp2_socket_pair_one_byte_at_a_time_request_response_with_trailing_metadata_and_payload_test",
"platforms": [
"windows",
"posix"
]
},
{
"flaky": false,
"language": "c",
@ -2558,6 +2620,15 @@
"posix"
]
},
{
"flaky": false,
"language": "c",
"name": "chttp2_fullstack_request_response_with_trailing_metadata_and_payload_unsecure_test",
"platforms": [
"windows",
"posix"
]
},
{
"flaky": false,
"language": "c",
@ -2771,6 +2842,14 @@
"posix"
]
},
{
"flaky": false,
"language": "c",
"name": "chttp2_fullstack_uds_posix_request_response_with_trailing_metadata_and_payload_unsecure_test",
"platforms": [
"posix"
]
},
{
"flaky": false,
"language": "c",
@ -3000,6 +3079,15 @@
"posix"
]
},
{
"flaky": false,
"language": "c",
"name": "chttp2_socket_pair_request_response_with_trailing_metadata_and_payload_unsecure_test",
"platforms": [
"windows",
"posix"
]
},
{
"flaky": false,
"language": "c",
@ -3234,6 +3322,15 @@
"posix"
]
},
{
"flaky": false,
"language": "c",
"name": "chttp2_socket_pair_one_byte_at_a_time_request_response_with_trailing_metadata_and_payload_unsecure_test",
"platforms": [
"windows",
"posix"
]
},
{
"flaky": false,
"language": "c",

File diff suppressed because one or more lines are too long

@ -161,6 +161,7 @@
<ClInclude Include="..\..\include\grpc\support\port_platform.h" />
<ClInclude Include="..\..\include\grpc\support\slice.h" />
<ClInclude Include="..\..\include\grpc\support\slice_buffer.h" />
<ClInclude Include="..\..\include\grpc\support\subprocess.h" />
<ClInclude Include="..\..\include\grpc\support\sync.h" />
<ClInclude Include="..\..\include\grpc\support\sync_generic.h" />
<ClInclude Include="..\..\include\grpc\support\sync_posix.h" />
@ -234,6 +235,8 @@
</ClCompile>
<ClCompile Include="..\..\src\core\support\string_win32.c">
</ClCompile>
<ClCompile Include="..\..\src\core\support\subprocess_posix.c">
</ClCompile>
<ClCompile Include="..\..\src\core\support\sync.c">
</ClCompile>
<ClCompile Include="..\..\src\core\support\sync_posix.c">
@ -252,6 +255,8 @@
</ClCompile>
<ClCompile Include="..\..\src\core\support\time_win32.c">
</ClCompile>
<ClCompile Include="..\..\src\core\support\tls_pthread.c">
</ClCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

@ -79,6 +79,9 @@
<ClCompile Include="..\..\src\core\support\string_win32.c">
<Filter>src\core\support</Filter>
</ClCompile>
<ClCompile Include="..\..\src\core\support\subprocess_posix.c">
<Filter>src\core\support</Filter>
</ClCompile>
<ClCompile Include="..\..\src\core\support\sync.c">
<Filter>src\core\support</Filter>
</ClCompile>
@ -106,6 +109,9 @@
<ClCompile Include="..\..\src\core\support\time_win32.c">
<Filter>src\core\support</Filter>
</ClCompile>
<ClCompile Include="..\..\src\core\support\tls_pthread.c">
<Filter>src\core\support</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\include\grpc\support\alloc.h">
@ -153,6 +159,9 @@
<ClInclude Include="..\..\include\grpc\support\slice_buffer.h">
<Filter>include\grpc\support</Filter>
</ClInclude>
<ClInclude Include="..\..\include\grpc\support\subprocess.h">
<Filter>include\grpc\support</Filter>
</ClInclude>
<ClInclude Include="..\..\include\grpc\support\sync.h">
<Filter>include\grpc\support</Filter>
</ClInclude>

@ -16,5 +16,7 @@ Build all flavors of gRPC C# extension and package them as a NuGet package.
```
buildall.bat
nuget pack grpc.native.csharp_ext
```
nuget pack grpc.native.csharp_ext.nuspec
```
When building the NuGet package, ignore the "Assembly outside lib folder" warnings (they DLLs are not assemblies, they are native libraries).

@ -1,5 +1,4 @@
@echo off
setlocal
REM setlocal
REM call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" amd64

@ -2,14 +2,14 @@
<package>
<metadata>
<id>grpc.native.csharp_ext</id>
<version>0.6.0.0</version>
<version>0.8.0.0</version>
<authors>Google Inc.</authors>
<owners>Jan Tattermusch</owners>
<licenseUrl>https://github.com/grpc/grpc/blob/master/LICENSE</licenseUrl>
<projectUrl>http://github.com/grpc/grpc</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Native extension needed by gRPC C# library. This is not the package you are looking for, it is only meant to be used as a dependency.</description>
<releaseNotes>Release of gRPC C core 0.6.0 libraries.</releaseNotes>
<releaseNotes>Release of gRPC C core 0.8.0 libraries.</releaseNotes>
<copyright>Copyright 2015</copyright>
<title>gRPC C# Native Extension</title>
<summary>Native library required by gRPC C#</summary>

Loading…
Cancel
Save