Merge github.com:grpc/grpc into c++api
Conflicts:
test/cpp/qps/server.cc
diff --git a/INSTALL b/INSTALL
index 7a3d02f..b7c1d46 100644
--- a/INSTALL
+++ b/INSTALL
@@ -100,16 +100,16 @@
A word on OpenSSL
-----------------
-Secure HTTP2 requires to have the TLS extension ALPN (see rfc 7301 and
+Secure HTTP2 requires the TLS extension ALPN (see rfc 7301 and
http://http2.github.io/http2-spec/ section 3.3). Our HTTP2 implementation
relies on OpenSSL's implementation. OpenSSL 1.0.2 is the first released version
of OpenSSL that has ALPN support, and this explains our dependency on it.
Note that the Makefile supports compiling only the unsecure elements of grpc,
and if you do not have OpenSSL and do not want it, you can still proceed
-with installing only the elements you require. However, it is recommended
-to encrypt your network traffic, therefore we urge you to not use the unsecure
-version of grpc if possible.
+with installing only the elements you require. However, we strongly recommend
+the use of encryption for all network traffic, and discourage the use of grpc
+without TLS.
Compiling
diff --git a/Makefile b/Makefile
index f2884fd..fa7eff7 100644
--- a/Makefile
+++ b/Makefile
@@ -1432,10 +1432,6 @@
$(Q) ./bins/$(CONFIG)/credentials_test || ( echo test credentials_test failed ; exit 1 )
$(E) "[RUN] Testing end2end_test"
$(Q) ./bins/$(CONFIG)/end2end_test || ( echo test end2end_test failed ; exit 1 )
- $(E) "[RUN] Testing qps_client"
- $(Q) ./bins/$(CONFIG)/qps_client || ( echo test qps_client failed ; exit 1 )
- $(E) "[RUN] Testing qps_server"
- $(Q) ./bins/$(CONFIG)/qps_server || ( echo test qps_server failed ; exit 1 )
$(E) "[RUN] Testing status_test"
$(Q) ./bins/$(CONFIG)/status_test || ( echo test status_test failed ; exit 1 )
$(E) "[RUN] Testing thread_pool_test"
diff --git a/build.json b/build.json
index 602d775..a528e89 100644
--- a/build.json
+++ b/build.json
@@ -1611,6 +1611,7 @@
{
"name": "qps_client",
"build": "test",
+ "run": false,
"language": "c++",
"src": [
"test/cpp/qps/qpstest.proto",
@@ -1628,6 +1629,7 @@
{
"name": "qps_server",
"build": "test",
+ "run": false,
"language": "c++",
"src": [
"test/cpp/qps/qpstest.proto",
diff --git a/src/core/iomgr/fd_posix.c b/src/core/iomgr/fd_posix.c
index b67c6cd..737ee01 100644
--- a/src/core/iomgr/fd_posix.c
+++ b/src/core/iomgr/fd_posix.c
@@ -68,7 +68,6 @@
static gpr_mu fd_freelist_mu;
static void freelist_fd(grpc_fd *fd) {
- gpr_free(fd->watchers);
gpr_mu_lock(&fd_freelist_mu);
fd->freelist_next = fd_freelist;
fd_freelist = fd;
@@ -93,9 +92,7 @@
gpr_atm_rel_store(&r->writest.state, NOT_READY);
gpr_atm_rel_store(&r->shutdown, 0);
r->fd = fd;
- r->watchers = NULL;
- r->watcher_count = 0;
- r->watcher_capacity = 0;
+ r->watcher_root.next = r->watcher_root.prev = &r->watcher_root;
r->freelist_next = NULL;
return r;
}
@@ -118,9 +115,7 @@
}
}
-void grpc_fd_global_init(void) {
- gpr_mu_init(&fd_freelist_mu);
-}
+void grpc_fd_global_init(void) { gpr_mu_init(&fd_freelist_mu); }
void grpc_fd_global_shutdown(void) {
while (fd_freelist != NULL) {
@@ -145,11 +140,11 @@
}
static void wake_watchers(grpc_fd *fd) {
- size_t i, n;
+ grpc_fd_watcher *watcher;
gpr_mu_lock(&fd->watcher_mu);
- n = fd->watcher_count;
- for (i = 0; i < n; i++) {
- grpc_pollset_force_kick(fd->watchers[i]);
+ for (watcher = fd->watcher_root.next; watcher != &fd->watcher_root;
+ watcher = watcher->next) {
+ grpc_pollset_force_kick(watcher->pollset);
}
gpr_mu_unlock(&fd->watcher_mu);
}
@@ -293,36 +288,27 @@
}
gpr_uint32 grpc_fd_begin_poll(grpc_fd *fd, grpc_pollset *pollset,
- gpr_uint32 read_mask, gpr_uint32 write_mask) {
+ gpr_uint32 read_mask, gpr_uint32 write_mask,
+ grpc_fd_watcher *watcher) {
/* keep track of pollers that have requested our events, in case they change
*/
gpr_mu_lock(&fd->watcher_mu);
- if (fd->watcher_capacity == fd->watcher_count) {
- fd->watcher_capacity =
- GPR_MAX(fd->watcher_capacity + 8, fd->watcher_capacity * 3 / 2);
- fd->watchers = gpr_realloc(fd->watchers,
- fd->watcher_capacity * sizeof(grpc_pollset *));
- }
- fd->watchers[fd->watcher_count++] = pollset;
+ watcher->next = &fd->watcher_root;
+ watcher->prev = watcher->next->prev;
+ watcher->next->prev = watcher->prev->next = watcher;
+ watcher->pollset = pollset;
+ watcher->fd = fd;
gpr_mu_unlock(&fd->watcher_mu);
return (gpr_atm_acq_load(&fd->readst.state) != READY ? read_mask : 0) |
(gpr_atm_acq_load(&fd->writest.state) != READY ? write_mask : 0);
}
-void grpc_fd_end_poll(grpc_fd *fd, grpc_pollset *pollset) {
- size_t r, w, n;
-
- gpr_mu_lock(&fd->watcher_mu);
- n = fd->watcher_count;
- for (r = 0, w = 0; r < n; r++) {
- if (fd->watchers[r] == pollset) {
- fd->watcher_count--;
- continue;
- }
- fd->watchers[w++] = fd->watchers[r];
- }
- gpr_mu_unlock(&fd->watcher_mu);
+void grpc_fd_end_poll(grpc_fd_watcher *watcher) {
+ gpr_mu_lock(&watcher->fd->watcher_mu);
+ watcher->next->prev = watcher->prev;
+ watcher->prev->next = watcher->next;
+ gpr_mu_unlock(&watcher->fd->watcher_mu);
}
void grpc_fd_become_readable(grpc_fd *fd, int allow_synchronous_callback) {
diff --git a/src/core/iomgr/fd_posix.h b/src/core/iomgr/fd_posix.h
index f42ae19..9a67508 100644
--- a/src/core/iomgr/fd_posix.h
+++ b/src/core/iomgr/fd_posix.h
@@ -47,7 +47,16 @@
gpr_atm state;
} grpc_fd_state;
-typedef struct grpc_fd {
+typedef struct grpc_fd grpc_fd;
+
+typedef struct grpc_fd_watcher {
+ struct grpc_fd_watcher *next;
+ struct grpc_fd_watcher *prev;
+ grpc_pollset *pollset;
+ grpc_fd *fd;
+} grpc_fd_watcher;
+
+struct grpc_fd {
int fd;
/* refst format:
bit0: 1=active/0=orphaned
@@ -60,9 +69,7 @@
gpr_atm shutdown;
gpr_mu watcher_mu;
- grpc_pollset **watchers;
- size_t watcher_count;
- size_t watcher_capacity;
+ grpc_fd_watcher watcher_root;
grpc_fd_state readst;
grpc_fd_state writest;
@@ -70,7 +77,7 @@
grpc_iomgr_cb_func on_done;
void *on_done_user_data;
struct grpc_fd *freelist_next;
-} grpc_fd;
+};
/* Create a wrapped file descriptor.
Requires fd is a non-blocking file descriptor.
@@ -95,9 +102,10 @@
Polling strategies that do not need to alter their behavior depending on the
fd's current interest (such as epoll) do not need to call this function. */
gpr_uint32 grpc_fd_begin_poll(grpc_fd *fd, grpc_pollset *pollset,
- gpr_uint32 read_mask, gpr_uint32 write_mask);
+ gpr_uint32 read_mask, gpr_uint32 write_mask,
+ grpc_fd_watcher *rec);
/* Complete polling previously started with grpc_fd_begin_poll */
-void grpc_fd_end_poll(grpc_fd *fd, grpc_pollset *pollset);
+void grpc_fd_end_poll(grpc_fd_watcher *rec);
/* Return 1 if this fd is orphaned, 0 otherwise */
int grpc_fd_is_orphaned(grpc_fd *fd);
diff --git a/src/core/iomgr/pollset_multipoller_with_poll_posix.c b/src/core/iomgr/pollset_multipoller_with_poll_posix.c
index e882969..3244ae0 100644
--- a/src/core/iomgr/pollset_multipoller_with_poll_posix.c
+++ b/src/core/iomgr/pollset_multipoller_with_poll_posix.c
@@ -53,11 +53,11 @@
size_t fd_count;
size_t fd_capacity;
grpc_fd **fds;
- /* fds being polled by the current poller: parallel arrays of pollfd and the
- * grpc_fd* that the pollfd was constructed from */
+ /* fds being polled by the current poller: parallel arrays of pollfd, and
+ a grpc_fd_watcher */
size_t pfd_count;
size_t pfd_capacity;
- grpc_fd **selfds;
+ grpc_fd_watcher *watchers;
struct pollfd *pfds;
/* fds that have been removed from the pollset explicitly */
size_t del_count;
@@ -98,7 +98,7 @@
pollset_hdr *h;
h = pollset->data.ptr;
for (i = 1; i < h->pfd_count; i++) {
- grpc_fd_end_poll(h->selfds[i], pollset);
+ grpc_fd_end_poll(&h->watchers[i]);
}
}
@@ -125,9 +125,9 @@
if (h->pfd_capacity < h->fd_count + 1) {
h->pfd_capacity = GPR_MAX(h->pfd_capacity * 3 / 2, h->fd_count + 1);
gpr_free(h->pfds);
- gpr_free(h->selfds);
+ gpr_free(h->watchers);
h->pfds = gpr_malloc(sizeof(struct pollfd) * h->pfd_capacity);
- h->selfds = gpr_malloc(sizeof(grpc_fd *) * h->pfd_capacity);
+ h->watchers = gpr_malloc(sizeof(grpc_fd_watcher) * h->pfd_capacity);
}
nf = 0;
np = 1;
@@ -147,7 +147,7 @@
grpc_fd_unref(h->fds[i]);
} else {
h->fds[nf++] = h->fds[i];
- h->selfds[np] = h->fds[i];
+ h->watchers[np].fd = h->fds[i];
h->pfds[np].fd = h->fds[i]->fd;
h->pfds[np].revents = 0;
np++;
@@ -167,8 +167,8 @@
gpr_mu_unlock(&pollset->mu);
for (i = 1; i < np; i++) {
- h->pfds[i].events =
- grpc_fd_begin_poll(h->selfds[i], pollset, POLLIN, POLLOUT);
+ h->pfds[i].events = grpc_fd_begin_poll(h->watchers[i].fd, pollset, POLLIN,
+ POLLOUT, &h->watchers[i]);
}
r = poll(h->pfds, h->pfd_count, timeout);
@@ -184,10 +184,10 @@
}
for (i = 1; i < np; i++) {
if (h->pfds[i].revents & POLLIN) {
- grpc_fd_become_readable(h->selfds[i], allow_synchronous_callback);
+ grpc_fd_become_readable(h->watchers[i].fd, allow_synchronous_callback);
}
if (h->pfds[i].revents & POLLOUT) {
- grpc_fd_become_writable(h->selfds[i], allow_synchronous_callback);
+ grpc_fd_become_writable(h->watchers[i].fd, allow_synchronous_callback);
}
}
}
@@ -211,7 +211,7 @@
grpc_fd_unref(h->dels[i]);
}
gpr_free(h->pfds);
- gpr_free(h->selfds);
+ gpr_free(h->watchers);
gpr_free(h->fds);
gpr_free(h->dels);
gpr_free(h);
@@ -234,7 +234,7 @@
h->pfd_count = 0;
h->pfd_capacity = 0;
h->pfds = NULL;
- h->selfds = NULL;
+ h->watchers = NULL;
h->del_count = 0;
h->del_capacity = 0;
h->dels = NULL;
diff --git a/src/core/iomgr/pollset_posix.c b/src/core/iomgr/pollset_posix.c
index b1c2c64..2837a0d 100644
--- a/src/core/iomgr/pollset_posix.c
+++ b/src/core/iomgr/pollset_posix.c
@@ -80,7 +80,9 @@
}
}
-void grpc_pollset_force_kick(grpc_pollset *p) { grpc_pollset_kick_kick(&p->kick_state); }
+void grpc_pollset_force_kick(grpc_pollset *p) {
+ grpc_pollset_kick_kick(&p->kick_state);
+}
/* global state management */
@@ -200,8 +202,15 @@
if (fd == pollset->data.ptr) return;
fds[0] = pollset->data.ptr;
fds[1] = fd;
- grpc_platform_become_multipoller(pollset, fds, GPR_ARRAY_SIZE(fds));
- grpc_fd_unref(fds[0]);
+ if (!grpc_fd_is_orphaned(fds[0])) {
+ grpc_platform_become_multipoller(pollset, fds, GPR_ARRAY_SIZE(fds));
+ grpc_fd_unref(fds[0]);
+ } else {
+ /* old fd is orphaned and we haven't cleaned it up until now, so remain a
+ * unary poller */
+ grpc_fd_unref(fds[0]);
+ pollset->data.ptr = fd;
+ }
}
static void unary_poll_pollset_del_fd(grpc_pollset *pollset, grpc_fd *fd) {
@@ -217,6 +226,7 @@
int allow_synchronous_callback) {
struct pollfd pfd[2];
grpc_fd *fd;
+ grpc_fd_watcher fd_watcher;
int timeout;
int r;
@@ -249,7 +259,7 @@
pollset->counter = 1;
gpr_mu_unlock(&pollset->mu);
- pfd[1].events = grpc_fd_begin_poll(fd, pollset, POLLIN, POLLOUT);
+ pfd[1].events = grpc_fd_begin_poll(fd, pollset, POLLIN, POLLOUT, &fd_watcher);
r = poll(pfd, GPR_ARRAY_SIZE(pfd), timeout);
if (r < 0) {
@@ -271,7 +281,7 @@
}
grpc_pollset_kick_post_poll(&pollset->kick_state);
- grpc_fd_end_poll(fd, pollset);
+ grpc_fd_end_poll(&fd_watcher);
gpr_mu_lock(&pollset->mu);
pollset->counter = 0;
diff --git a/src/core/surface/call.c b/src/core/surface/call.c
index cc7094a..b31f4f1 100644
--- a/src/core/surface/call.c
+++ b/src/core/surface/call.c
@@ -1264,7 +1264,10 @@
ls = get_legacy_state(call);
err = bind_cq(call, cq);
- if (err != GRPC_CALL_OK) return err;
+ if (err != GRPC_CALL_OK) {
+ unlock(call);
+ return err;
+ }
ls->finished_tag = finished_tag;
diff --git a/src/csharp/.gitignore b/src/csharp/.gitignore
index dbf38f3..d35ff63 100644
--- a/src/csharp/.gitignore
+++ b/src/csharp/.gitignore
@@ -1,2 +1,4 @@
*.userprefs
test-results
+packages
+Grpc.v12.suo
diff --git a/src/csharp/GrpcApi/.gitignore b/src/csharp/GrpcApi/.gitignore
index 2cc8cca..4795a95 100644
--- a/src/csharp/GrpcApi/.gitignore
+++ b/src/csharp/GrpcApi/.gitignore
@@ -1,2 +1,3 @@
test-results
bin
+obj
diff --git a/src/csharp/GrpcApi/GrpcApi.csproj b/src/csharp/GrpcApi/GrpcApi.csproj
index f0f11de..5a4ae67 100644
--- a/src/csharp/GrpcApi/GrpcApi.csproj
+++ b/src/csharp/GrpcApi/GrpcApi.csproj
@@ -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>
@@ -30,19 +30,23 @@
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<ItemGroup>
+ <Reference Include="Google.ProtocolBuffers, Version=2.4.1.521, Culture=neutral, PublicKeyToken=55f7125234beb589, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\packages\Google.ProtocolBuffers.2.4.1.521\lib\net40\Google.ProtocolBuffers.dll</HintPath>
+ </Reference>
<Reference Include="System" />
- <Reference Include="System.Reactive.Linq, Version=2.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
- <Private>False</Private>
+ <Reference Include="System.Reactive.Core">
+ <HintPath>..\packages\Rx-Core.2.2.5\lib\net45\System.Reactive.Core.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Reactive.Interfaces">
+ <HintPath>..\packages\Rx-Interfaces.2.2.5\lib\net45\System.Reactive.Interfaces.dll</HintPath>
</Reference>
<Reference Include="System.Data.Linq" />
- <Reference Include="System.Reactive.Interfaces, Version=2.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
- <Private>False</Private>
+ <Reference Include="System.Reactive.Linq">
+ <HintPath>..\packages\Rx-Linq.2.2.5\lib\net45\System.Reactive.Linq.dll</HintPath>
</Reference>
- <Reference Include="System.Reactive.Core, Version=2.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
- <Private>False</Private>
- </Reference>
- <Reference Include="Google.ProtocolBuffers">
- <HintPath>..\lib\Google.ProtocolBuffers.dll</HintPath>
+ <Reference Include="System.Reactive.PlatformServices">
+ <HintPath>..\packages\Rx-PlatformServices.2.2.5\lib\net45\System.Reactive.PlatformServices.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
@@ -63,12 +67,10 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
+ <None Include="packages.config" />
<None Include="proto\math.proto" />
<None Include="proto\empty.proto" />
<None Include="proto\messages.proto" />
<None Include="proto\test.proto" />
</ItemGroup>
- <ItemGroup>
- <Folder Include="proto\" />
- </ItemGroup>
</Project>
\ No newline at end of file
diff --git a/src/csharp/GrpcApi/packages.config b/src/csharp/GrpcApi/packages.config
new file mode 100644
index 0000000..a6a949b
--- /dev/null
+++ b/src/csharp/GrpcApi/packages.config
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="Google.ProtocolBuffers" version="2.4.1.521" targetFramework="net45" />
+ <package id="Ix-Main" version="1.2.3" targetFramework="net45" />
+ <package id="NUnit" version="2.6.4" targetFramework="net45" />
+ <package id="Rx-Core" version="2.2.5" targetFramework="net45" />
+ <package id="Rx-Interfaces" version="2.2.5" targetFramework="net45" />
+ <package id="Rx-Linq" version="2.2.5" targetFramework="net45" />
+ <package id="Rx-Main" version="2.2.5" targetFramework="net45" />
+ <package id="Rx-PlatformServices" version="2.2.5" targetFramework="net45" />
+</packages>
\ No newline at end of file
diff --git a/src/csharp/GrpcApiTests/.gitignore b/src/csharp/GrpcApiTests/.gitignore
index 2cc8cca..4795a95 100644
--- a/src/csharp/GrpcApiTests/.gitignore
+++ b/src/csharp/GrpcApiTests/.gitignore
@@ -1,2 +1,3 @@
test-results
bin
+obj
diff --git a/src/csharp/GrpcApiTests/GrpcApiTests.csproj b/src/csharp/GrpcApiTests/GrpcApiTests.csproj
index d0aac2b..cb955cf 100644
--- a/src/csharp/GrpcApiTests/GrpcApiTests.csproj
+++ b/src/csharp/GrpcApiTests/GrpcApiTests.csproj
@@ -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>
@@ -30,13 +30,14 @@
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<ItemGroup>
+ <Reference Include="Google.ProtocolBuffers, Version=2.4.1.521, Culture=neutral, PublicKeyToken=55f7125234beb589, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\packages\Google.ProtocolBuffers.2.4.1.521\lib\net40\Google.ProtocolBuffers.dll</HintPath>
+ </Reference>
+ <Reference Include="nunit.framework">
+ <HintPath>..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
+ </Reference>
<Reference Include="System" />
- <Reference Include="nunit.framework, Version=2.6.0.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77">
- <Private>False</Private>
- </Reference>
- <Reference Include="Google.ProtocolBuffers">
- <HintPath>..\lib\Google.ProtocolBuffers.dll</HintPath>
- </Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
@@ -53,4 +54,10 @@
<Name>GrpcCore</Name>
</ProjectReference>
</ItemGroup>
+ <ItemGroup>
+ <None Include="packages.config" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
</Project>
\ No newline at end of file
diff --git a/src/csharp/GrpcApiTests/packages.config b/src/csharp/GrpcApiTests/packages.config
new file mode 100644
index 0000000..51c17bc
--- /dev/null
+++ b/src/csharp/GrpcApiTests/packages.config
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="Google.ProtocolBuffers" version="2.4.1.521" targetFramework="net45" />
+ <package id="NUnit" version="2.6.4" targetFramework="net45" />
+</packages>
\ No newline at end of file
diff --git a/src/csharp/GrpcCore/.gitignore b/src/csharp/GrpcCore/.gitignore
index ba077a4..8d4a6c0 100644
--- a/src/csharp/GrpcCore/.gitignore
+++ b/src/csharp/GrpcCore/.gitignore
@@ -1 +1,2 @@
bin
+obj
\ No newline at end of file
diff --git a/src/csharp/GrpcCoreTests/.gitignore b/src/csharp/GrpcCoreTests/.gitignore
index 2cc8cca..775a944 100644
--- a/src/csharp/GrpcCoreTests/.gitignore
+++ b/src/csharp/GrpcCoreTests/.gitignore
@@ -1,2 +1,3 @@
test-results
bin
+obj
\ No newline at end of file
diff --git a/src/csharp/GrpcCoreTests/GrpcCoreTests.csproj b/src/csharp/GrpcCoreTests/GrpcCoreTests.csproj
index 111f088..ca52cd8 100644
--- a/src/csharp/GrpcCoreTests/GrpcCoreTests.csproj
+++ b/src/csharp/GrpcCoreTests/GrpcCoreTests.csproj
@@ -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>
@@ -30,10 +30,10 @@
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<ItemGroup>
- <Reference Include="System" />
- <Reference Include="nunit.framework, Version=2.6.0.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77">
- <Private>False</Private>
+ <Reference Include="nunit.framework">
+ <HintPath>..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
</Reference>
+ <Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
@@ -49,4 +49,10 @@
<Name>GrpcCore</Name>
</ProjectReference>
</ItemGroup>
+ <ItemGroup>
+ <None Include="packages.config" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
</Project>
\ No newline at end of file
diff --git a/src/csharp/GrpcCoreTests/packages.config b/src/csharp/GrpcCoreTests/packages.config
new file mode 100644
index 0000000..c714ef3
--- /dev/null
+++ b/src/csharp/GrpcCoreTests/packages.config
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="NUnit" version="2.6.4" targetFramework="net45" />
+</packages>
\ No newline at end of file
diff --git a/src/csharp/InteropClient/.gitignore b/src/csharp/InteropClient/.gitignore
index ba077a4..8d4a6c0 100644
--- a/src/csharp/InteropClient/.gitignore
+++ b/src/csharp/InteropClient/.gitignore
@@ -1 +1,2 @@
bin
+obj
\ No newline at end of file
diff --git a/src/csharp/InteropClient/InteropClient.csproj b/src/csharp/InteropClient/InteropClient.csproj
index b8e099d..a450f3a 100644
--- a/src/csharp/InteropClient/InteropClient.csproj
+++ b/src/csharp/InteropClient/InteropClient.csproj
@@ -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>
@@ -33,13 +33,14 @@
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<ItemGroup>
+ <Reference Include="Google.ProtocolBuffers, Version=2.4.1.521, Culture=neutral, PublicKeyToken=55f7125234beb589, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\packages\Google.ProtocolBuffers.2.4.1.521\lib\net40\Google.ProtocolBuffers.dll</HintPath>
+ </Reference>
+ <Reference Include="nunit.framework">
+ <HintPath>..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
+ </Reference>
<Reference Include="System" />
- <Reference Include="nunit.framework, Version=2.6.0.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77">
- <Private>False</Private>
- </Reference>
- <Reference Include="Google.ProtocolBuffers">
- <HintPath>..\lib\Google.ProtocolBuffers.dll</HintPath>
- </Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
@@ -56,4 +57,7 @@
<Name>GrpcApi</Name>
</ProjectReference>
</ItemGroup>
+ <ItemGroup>
+ <None Include="packages.config" />
+ </ItemGroup>
</Project>
\ No newline at end of file
diff --git a/src/csharp/InteropClient/packages.config b/src/csharp/InteropClient/packages.config
new file mode 100644
index 0000000..51c17bc
--- /dev/null
+++ b/src/csharp/InteropClient/packages.config
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="Google.ProtocolBuffers" version="2.4.1.521" targetFramework="net45" />
+ <package id="NUnit" version="2.6.4" targetFramework="net45" />
+</packages>
\ No newline at end of file
diff --git a/src/csharp/MathClient/.gitignore b/src/csharp/MathClient/.gitignore
index ba077a4..1746e32 100644
--- a/src/csharp/MathClient/.gitignore
+++ b/src/csharp/MathClient/.gitignore
@@ -1 +1,2 @@
bin
+obj
diff --git a/src/csharp/README.md b/src/csharp/README.md
index 0df6925..a16f1e7 100755
--- a/src/csharp/README.md
+++ b/src/csharp/README.md
@@ -15,8 +15,15 @@
completely rewritten.
-INSTALLATION AND USAGE
-----------------------
+INSTALLATION AND USAGE: WINDOWS
+-------------------------------
+
+- Open Grpc.sln using Visual Studio 2013. NuGet dependencies will be restored
+ upon build.
+
+
+INSTALLATION AND USAGE: LINUX & MONO
+------------------------------------
- Compile and install the gRPC C Core library
```
@@ -31,6 +38,18 @@
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:
+
+```
+# 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
+```
+
- Use MonoDevelop to open the solution Grpc.sln (you can also run unit tests
from there).
diff --git a/src/csharp/lib/Google.ProtocolBuffers.dll b/src/csharp/lib/Google.ProtocolBuffers.dll
deleted file mode 100755
index ce2f466..0000000
--- a/src/csharp/lib/Google.ProtocolBuffers.dll
+++ /dev/null
Binary files differ
diff --git a/src/python/setup.py b/src/python/setup.py
index 58dc3b1..5e566ba 100644
--- a/src/python/setup.py
+++ b/src/python/setup.py
@@ -38,6 +38,7 @@
'src/_adapter/_completion_queue.c',
'src/_adapter/_error.c',
'src/_adapter/_server.c',
+ 'src/_adapter/_server_credentials.c',
)
_EXTENSION_INCLUDE_DIRECTORIES = (
diff --git a/src/python/src/_adapter/_c.c b/src/python/src/_adapter/_c.c
index d1f7fbb..6fb7fa2 100644
--- a/src/python/src/_adapter/_c.c
+++ b/src/python/src/_adapter/_c.c
@@ -38,6 +38,7 @@
#include "_adapter/_channel.h"
#include "_adapter/_call.h"
#include "_adapter/_server.h"
+#include "_adapter/_server_credentials.h"
static PyObject *init(PyObject *self, PyObject *args) {
grpc_init();
@@ -74,4 +75,7 @@
if (pygrpc_add_server(module) == -1) {
return;
}
+ if (pygrpc_add_server_credentials(module) == -1) {
+ return;
+ }
}
diff --git a/src/python/src/_adapter/_c_test.py b/src/python/src/_adapter/_c_test.py
index bc0a622..19c91ff 100644
--- a/src/python/src/_adapter/_c_test.py
+++ b/src/python/src/_adapter/_c_test.py
@@ -136,6 +136,32 @@
_c.shut_down()
+ def test_server_credentials(self):
+ root_certificates = b'Trust starts here. Really.'
+ first_private_key = b'This is a really bad private key, yo.'
+ first_certificate_chain = b'Trust me! Do I not look trustworty?'
+ second_private_key = b'This is another bad private key, yo.'
+ second_certificate_chain = b'Look into my eyes; you can totes trust me.'
+
+ _c.init()
+
+ server_credentials = _c.ServerCredentials(
+ None, ((first_private_key, first_certificate_chain),))
+ del server_credentials
+ server_credentials = _c.ServerCredentials(
+ root_certificates, ((first_private_key, first_certificate_chain),))
+ del server_credentials
+ server_credentials = _c.ServerCredentials(
+ root_certificates,
+ ((first_private_key, first_certificate_chain),
+ (second_private_key, second_certificate_chain),))
+ del server_credentials
+ with self.assertRaises(TypeError):
+ _c.ServerCredentials(
+ root_certificates, first_private_key, second_certificate_chain)
+
+ _c.shut_down()
+
if __name__ == '__main__':
unittest.main()
diff --git a/src/python/src/_adapter/_server_credentials.c b/src/python/src/_adapter/_server_credentials.c
new file mode 100644
index 0000000..390266a
--- /dev/null
+++ b/src/python/src/_adapter/_server_credentials.c
@@ -0,0 +1,157 @@
+/*
+ *
+ * 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 "_adapter/_server_credentials.h"
+
+#include <Python.h>
+#include <grpc/grpc_security.h>
+#include <grpc/support/alloc.h>
+
+static int pygrpc_server_credentials_init(ServerCredentials *self,
+ PyObject *args, PyObject *kwds) {
+ char *root_certificates;
+ PyObject *pair_sequence;
+ Py_ssize_t pair_count;
+ grpc_ssl_pem_key_cert_pair *pairs;
+ int error;
+ PyObject *iterator;
+ int i;
+ PyObject *pair;
+
+ if (!(PyArg_ParseTuple(args, "zO", &root_certificates, &pair_sequence))) {
+ self->c_server_credentials = NULL;
+ return -1;
+ }
+
+ pair_count = PySequence_Length(pair_sequence);
+ if (pair_count == -1) {
+ self->c_server_credentials = NULL;
+ return -1;
+ }
+
+ iterator = PyObject_GetIter(pair_sequence);
+ if (iterator == NULL) {
+ self->c_server_credentials = NULL;
+ return -1;
+ }
+ pairs = gpr_malloc(pair_count * sizeof(grpc_ssl_pem_key_cert_pair));
+ error = 0;
+ for (i = 0; i < pair_count; i++) {
+ pair = PyIter_Next(iterator);
+ if (pair == NULL) {
+ error = 1;
+ break;
+ }
+ if (!(PyArg_ParseTuple(pair, "ss", &pairs[i].private_key,
+ &pairs[i].cert_chain))) {
+ error = 1;
+ Py_DECREF(pair);
+ break;
+ }
+ Py_DECREF(pair);
+ }
+ Py_DECREF(iterator);
+
+ if (error) {
+ self->c_server_credentials = NULL;
+ gpr_free(pairs);
+ return -1;
+ } else {
+ self->c_server_credentials = grpc_ssl_server_credentials_create(
+ root_certificates, pairs, pair_count);
+ gpr_free(pairs);
+ return 0;
+ }
+}
+
+static void pygrpc_server_credentials_dealloc(ServerCredentials *self) {
+ if (self->c_server_credentials != NULL) {
+ grpc_server_credentials_release(self->c_server_credentials);
+ }
+ self->ob_type->tp_free((PyObject *)self);
+}
+
+PyTypeObject pygrpc_ServerCredentialsType = {
+ PyObject_HEAD_INIT(NULL)0, /*ob_size*/
+ "_grpc.ServerCredencials", /*tp_name*/
+ sizeof(ServerCredentials), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ (destructor)pygrpc_server_credentials_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ "Wrapping of grpc_server_credentials.", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ 0, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)pygrpc_server_credentials_init, /* tp_init */
+};
+
+int pygrpc_add_server_credentials(PyObject *module) {
+ pygrpc_ServerCredentialsType.tp_new = PyType_GenericNew;
+ if (PyType_Ready(&pygrpc_ServerCredentialsType) < 0) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "Error defining pygrpc_ServerCredentialsType!");
+ return -1;
+ }
+ if (PyModule_AddObject(module, "ServerCredentials",
+ (PyObject *)&pygrpc_ServerCredentialsType) == -1) {
+ PyErr_SetString(PyExc_ImportError,
+ "Couldn't add ServerCredentials type to module!");
+ return -1;
+ }
+ return 0;
+}
diff --git a/src/python/src/_adapter/_server_credentials.h b/src/python/src/_adapter/_server_credentials.h
new file mode 100644
index 0000000..2e56efd
--- /dev/null
+++ b/src/python/src/_adapter/_server_credentials.h
@@ -0,0 +1,48 @@
+/*
+ *
+ * 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 _ADAPTER__SERVER_CREDENTIALS_H_
+#define _ADAPTER__SERVER_CREDENTIALS_H_
+
+#include <Python.h>
+#include <grpc/grpc_security.h>
+
+typedef struct {
+ PyObject_HEAD grpc_server_credentials *c_server_credentials;
+} ServerCredentials;
+
+PyTypeObject pygrpc_ServerCredentialsType;
+
+int pygrpc_add_server_credentials(PyObject *module);
+
+#endif /* _ADAPTER__SERVER_CREDENTIALS_H_ */
diff --git a/test/cpp/qps/server.cc b/test/cpp/qps/server.cc
index 4e1d2ca..7180461 100644
--- a/test/cpp/qps/server.cc
+++ b/test/cpp/qps/server.cc
@@ -44,6 +44,7 @@
#include <grpc++/server_builder.h>
#include <grpc++/server_context.h>
#include <grpc++/status.h>
+#include "src/cpp/server/thread_pool.h"
#include "test/core/util/grpc_profiler.h"
#include "test/cpp/qps/qpstest.pb.h"
@@ -52,10 +53,12 @@
DEFINE_bool(enable_ssl, false, "Whether to use ssl/tls.");
DEFINE_int32(port, 0, "Server port.");
+DEFINE_int32(server_threads, 4, "Number of server threads.");
using grpc::Server;
using grpc::ServerBuilder;
using grpc::ServerContext;
+using grpc::ThreadPool;
using grpc::testing::Payload;
using grpc::testing::PayloadType;
using grpc::testing::ServerStats;
@@ -126,6 +129,10 @@
ServerBuilder builder;
builder.AddPort(server_address);
builder.RegisterService(&service);
+
+ std::unique_ptr<ThreadPool> pool(new ThreadPool(FLAGS_server_threads));
+ builder.SetThreadPool(pool.get());
+
std::unique_ptr<Server> server(builder.BuildAndStart());
gpr_log(GPR_INFO, "Server listening on %s\n", server_address);
diff --git a/tools/run_tests/build_python.sh b/tools/run_tests/build_python.sh
index 4abb412..b45b9d6 100755
--- a/tools/run_tests/build_python.sh
+++ b/tools/run_tests/build_python.sh
@@ -5,7 +5,11 @@
# change to grpc repo root
cd $(dirname $0)/../..
+make -j6
+
root=`pwd`
virtualenv python2.7_virtual_environment
-python2.7_virtual_environment/bin/pip install enum34==1.0.4 futures==2.2.0 protobuf==2.6.1
-python2.7_virtual_environment/bin/pip install src/python
+ln -sf $root/include/grpc python2.7_virtual_environment/include/grpc
+source python2.7_virtual_environment/bin/activate
+pip install enum34==1.0.4 futures==2.2.0 protobuf==2.6.1
+CFLAGS=-I$root/include LDFLAGS=-L$root/libs/opt pip install src/python
diff --git a/tools/run_tests/run_python.sh b/tools/run_tests/run_python.sh
index 6e9405a..7d3ee73 100755
--- a/tools/run_tests/run_python.sh
+++ b/tools/run_tests/run_python.sh
@@ -6,19 +6,21 @@
cd $(dirname $0)/../..
root=`pwd`
+export LD_LIBRARY_PATH=$root/libs/opt
+source python2.7_virtual_environment/bin/activate
# TODO(issue 215): Properly itemize these in run_tests.py so that they can be parallelized.
-python2.7_virtual_environment/bin/python2.7 -B -m _adapter._blocking_invocation_inline_service_test
-python2.7_virtual_environment/bin/python2.7 -B -m _adapter._c_test
-python2.7_virtual_environment/bin/python2.7 -B -m _adapter._event_invocation_synchronous_event_service_test
-python2.7_virtual_environment/bin/python2.7 -B -m _adapter._future_invocation_asynchronous_event_service_test
-python2.7_virtual_environment/bin/python2.7 -B -m _adapter._links_test
-python2.7_virtual_environment/bin/python2.7 -B -m _adapter._lonely_rear_link_test
-python2.7_virtual_environment/bin/python2.7 -B -m _adapter._low_test
-python2.7_virtual_environment/bin/python2.7 -B -m _framework.base.packets.implementations_test
-python2.7_virtual_environment/bin/python2.7 -B -m _framework.face.blocking_invocation_inline_service_test
-python2.7_virtual_environment/bin/python2.7 -B -m _framework.face.event_invocation_synchronous_event_service_test
-python2.7_virtual_environment/bin/python2.7 -B -m _framework.face.future_invocation_asynchronous_event_service_test
-python2.7_virtual_environment/bin/python2.7 -B -m _framework.foundation._later_test
-python2.7_virtual_environment/bin/python2.7 -B -m _framework.foundation._logging_pool_test
+python2.7 -B -m _adapter._blocking_invocation_inline_service_test
+python2.7 -B -m _adapter._c_test
+python2.7 -B -m _adapter._event_invocation_synchronous_event_service_test
+python2.7 -B -m _adapter._future_invocation_asynchronous_event_service_test
+python2.7 -B -m _adapter._links_test
+python2.7 -B -m _adapter._lonely_rear_link_test
+python2.7 -B -m _adapter._low_test
+python2.7 -B -m _framework.base.packets.implementations_test
+python2.7 -B -m _framework.face.blocking_invocation_inline_service_test
+python2.7 -B -m _framework.face.event_invocation_synchronous_event_service_test
+python2.7 -B -m _framework.face.future_invocation_asynchronous_event_service_test
+python2.7 -B -m _framework.foundation._later_test
+python2.7 -B -m _framework.foundation._logging_pool_test
# TODO(nathaniel): Get tests working under 3.4 (requires 3.X-friendly protobuf)
# python3.4 -B -m unittest discover -s src/python -p '*.py'