aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Julien Boeuf <jboeuf@google.com>2016-01-28 15:45:08 -0800
committerGravatar Julien Boeuf <jboeuf@google.com>2016-01-28 15:45:08 -0800
commit54cc08c216ea23a85e122ef19a30ffe3399255e9 (patch)
treea923c2e552c2827bd7491b19ff63443e7c2fdcef /src
parenta50da4757ae7eb75b67d78b7e82fba79d2c987da (diff)
parent822602cff0f3b1f8373ac06a8ab8fe9792b1037e (diff)
Merge branch 'master' of github.com:grpc/grpc into ssl_credentials_override_default_roots
Diffstat (limited to 'src')
-rwxr-xr-xsrc/boringssl/gen_build_yaml.py5
-rw-r--r--src/core/channel/channel_args.c7
-rw-r--r--src/core/client_config/subchannel.c14
-rw-r--r--src/core/iomgr/iocp_windows.c6
-rw-r--r--src/core/iomgr/pollset_windows.c11
-rw-r--r--src/core/iomgr/sockaddr_win32.h7
-rw-r--r--src/core/iomgr/tcp_server_windows.c2
-rw-r--r--src/core/iomgr/tcp_windows.c6
-rw-r--r--src/core/iomgr/udp_server.c12
-rw-r--r--src/core/iomgr/udp_server.h10
-rw-r--r--src/core/support/env_win32.c22
-rw-r--r--src/core/support/log_win32.c6
-rw-r--r--src/core/support/string_win32.c10
-rw-r--r--src/core/support/sync_win32.c8
-rw-r--r--src/core/support/time_win32.c21
-rw-r--r--src/core/surface/server.c6
-rw-r--r--src/core/surface/server_create.c5
-rw-r--r--src/proto/grpc/testing/echo_messages.proto3
-rw-r--r--src/python/grpcio/commands.py130
-rwxr-xr-xsrc/zlib/gen_build_yaml.py1
20 files changed, 207 insertions, 85 deletions
diff --git a/src/boringssl/gen_build_yaml.py b/src/boringssl/gen_build_yaml.py
index b635ee4c13..7c7a57993f 100755
--- a/src/boringssl/gen_build_yaml.py
+++ b/src/boringssl/gen_build_yaml.py
@@ -82,6 +82,7 @@ class Grpc(object):
for f in files['ssl_headers'] + files['ssl_internal_headers'] + files['crypto_headers'] + files['crypto_internal_headers']
),
'boringssl': True,
+ 'defaults': 'boringssl',
},
{
'name': 'boringssl_test_util',
@@ -89,6 +90,7 @@ class Grpc(object):
'language': 'c++',
'secure': 'no',
'boringssl': True,
+ 'defaults': 'boringssl',
'src': [
map_dir(f)
for f in sorted(files['test_support'])
@@ -103,6 +105,7 @@ class Grpc(object):
'src': [map_dir(test)],
'vs_proj_dir': 'test/boringssl',
'boringssl': True,
+ 'defaults': 'boringssl',
'deps': [
'boringssl_test_util',
'boringssl',
@@ -120,6 +123,7 @@ class Grpc(object):
'src': [],
'vs_proj_dir': 'test/boringssl',
'boringssl': True,
+ 'defaults': 'boringssl',
'deps': [
'boringssl_%s_lib' % os.path.splitext(os.path.basename(test))[0],
'boringssl_test_util',
@@ -138,6 +142,7 @@ class Grpc(object):
'flaky': False,
'language': 'c++',
'boringssl': True,
+ 'defaults': 'boringssl',
'cpu_cost': 1.0
}
for test in files['tests']
diff --git a/src/core/channel/channel_args.c b/src/core/channel/channel_args.c
index 487db1119a..0427ce0b8d 100644
--- a/src/core/channel/channel_args.c
+++ b/src/core/channel/channel_args.c
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -35,6 +35,7 @@
#include "src/core/channel/channel_args.h"
#include "src/core/support/string.h"
+#include <grpc/census.h>
#include <grpc/support/alloc.h>
#include <grpc/support/string_util.h>
#include <grpc/support/useful.h>
@@ -119,10 +120,10 @@ int grpc_channel_args_is_census_enabled(const grpc_channel_args *a) {
if (a == NULL) return 0;
for (i = 0; i < a->num_args; i++) {
if (0 == strcmp(a->args[i].key, GRPC_ARG_ENABLE_CENSUS)) {
- return a->args[i].value.integer != 0;
+ return a->args[i].value.integer != 0 && census_enabled();
}
}
- return 0;
+ return census_enabled();
}
grpc_compression_algorithm grpc_channel_args_get_compression_algorithm(
diff --git a/src/core/client_config/subchannel.c b/src/core/client_config/subchannel.c
index 748eef9bed..fccc1dda54 100644
--- a/src/core/client_config/subchannel.c
+++ b/src/core/client_config/subchannel.c
@@ -284,9 +284,13 @@ grpc_subchannel *grpc_subchannel_create(grpc_connector *connector,
c->connector = connector;
grpc_connector_ref(c->connector);
c->num_filters = args->filter_count;
- c->filters = gpr_malloc(sizeof(grpc_channel_filter *) * c->num_filters);
- memcpy((void *)c->filters, args->filters,
- sizeof(grpc_channel_filter *) * c->num_filters);
+ if (c->num_filters > 0) {
+ c->filters = gpr_malloc(sizeof(grpc_channel_filter *) * c->num_filters);
+ memcpy((void *)c->filters, args->filters,
+ sizeof(grpc_channel_filter *) * c->num_filters);
+ } else {
+ c->filters = NULL;
+ }
c->addr = gpr_malloc(args->addr_len);
memcpy(c->addr, args->addr, args->addr_len);
grpc_pollset_set_init(&c->pollset_set);
@@ -483,7 +487,9 @@ static void publish_transport(grpc_exec_ctx *exec_ctx, grpc_subchannel *c) {
/* build final filter list */
num_filters = c->num_filters + c->connecting_result.num_filters + 1;
filters = gpr_malloc(sizeof(*filters) * num_filters);
- memcpy((void *)filters, c->filters, sizeof(*filters) * c->num_filters);
+ if (c->num_filters > 0) {
+ memcpy((void *)filters, c->filters, sizeof(*filters) * c->num_filters);
+ }
memcpy((void *)(filters + c->num_filters), c->connecting_result.filters,
sizeof(*filters) * c->connecting_result.num_filters);
filters[num_filters - 1] = &grpc_connected_channel_filter;
diff --git a/src/core/iomgr/iocp_windows.c b/src/core/iomgr/iocp_windows.c
index d3868ce62c..6cbe7d2fd4 100644
--- a/src/core/iomgr/iocp_windows.c
+++ b/src/core/iomgr/iocp_windows.c
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -67,7 +67,7 @@ static DWORD deadline_to_millis_timeout(gpr_timespec deadline,
return 0;
}
timeout = gpr_time_sub(deadline, now);
- return gpr_time_to_millis(gpr_time_add(
+ return (DWORD)gpr_time_to_millis(gpr_time_add(
timeout, gpr_time_from_nanos(GPR_NS_PER_MS - 1, GPR_TIMESPAN)));
}
@@ -179,11 +179,9 @@ void grpc_iocp_add_socket(grpc_winsocket *socket) {
static void socket_notify_on_iocp(grpc_exec_ctx *exec_ctx,
grpc_winsocket *socket, grpc_closure *closure,
grpc_winsocket_callback_info *info) {
- int run_now = 0;
GPR_ASSERT(info->closure == NULL);
gpr_mu_lock(&socket->state_mu);
if (info->has_pending_iocp) {
- run_now = 1;
info->has_pending_iocp = 0;
grpc_exec_ctx_enqueue(exec_ctx, closure, 1);
} else {
diff --git a/src/core/iomgr/pollset_windows.c b/src/core/iomgr/pollset_windows.c
index deb661548d..bfd9e69a16 100644
--- a/src/core/iomgr/pollset_windows.c
+++ b/src/core/iomgr/pollset_windows.c
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -81,15 +81,6 @@ static grpc_pollset_worker *pop_front_worker(
}
}
-static void push_back_worker(grpc_pollset_worker *root,
- grpc_pollset_worker_link_type type,
- grpc_pollset_worker *worker) {
- worker->links[type].next = root;
- worker->links[type].prev = worker->links[type].next->links[type].prev;
- worker->links[type].prev->links[type].next =
- worker->links[type].next->links[type].prev = worker;
-}
-
static void push_front_worker(grpc_pollset_worker *root,
grpc_pollset_worker_link_type type,
grpc_pollset_worker *worker) {
diff --git a/src/core/iomgr/sockaddr_win32.h b/src/core/iomgr/sockaddr_win32.h
index fe2be99145..8e3946a7d8 100644
--- a/src/core/iomgr/sockaddr_win32.h
+++ b/src/core/iomgr/sockaddr_win32.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -38,9 +38,4 @@
#include <ws2tcpip.h>
#include <mswsock.h>
-#ifdef __MINGW32__
-/* mingw seems to be missing that definition. */
-const char *inet_ntop(int af, const void *src, char *dst, socklen_t size);
-#endif
-
#endif /* GRPC_INTERNAL_CORE_IOMGR_SOCKADDR_WIN32_H */
diff --git a/src/core/iomgr/tcp_server_windows.c b/src/core/iomgr/tcp_server_windows.c
index 8ee8149f25..00d381f264 100644
--- a/src/core/iomgr/tcp_server_windows.c
+++ b/src/core/iomgr/tcp_server_windows.c
@@ -531,7 +531,7 @@ int grpc_tcp_server_port_fd(grpc_tcp_server *s, unsigned port_index,
for (sp = s->head; sp && port_index != 0; sp = sp->next, --port_index)
;
if (sp) {
- return _open_osfhandle(sp->socket->socket, 0);
+ return _open_osfhandle((intptr_t)sp->socket->socket, 0);
} else {
return -1;
}
diff --git a/src/core/iomgr/tcp_windows.c b/src/core/iomgr/tcp_windows.c
index cc7f7ff8d2..d3f080cbf9 100644
--- a/src/core/iomgr/tcp_windows.c
+++ b/src/core/iomgr/tcp_windows.c
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -143,10 +143,7 @@ static void on_read(grpc_exec_ctx *exec_ctx, void *tcpp, int success) {
grpc_closure *cb = tcp->read_cb;
grpc_winsocket *socket = tcp->socket;
gpr_slice sub;
- gpr_slice *slice = NULL;
- size_t nslices = 0;
grpc_winsocket_callback_info *info = &socket->read_info;
- int do_abort = 0;
if (success) {
if (socket->read_info.wsa_error != 0 && !tcp->shutting_down) {
@@ -238,7 +235,6 @@ static void on_write(grpc_exec_ctx *exec_ctx, void *tcpp, int success) {
grpc_winsocket *handle = tcp->socket;
grpc_winsocket_callback_info *info = &handle->write_info;
grpc_closure *cb;
- int do_abort = 0;
gpr_mu_lock(&tcp->mu);
cb = tcp->write_cb;
diff --git a/src/core/iomgr/udp_server.c b/src/core/iomgr/udp_server.c
index a1a6b04cad..fe006c603c 100644
--- a/src/core/iomgr/udp_server.c
+++ b/src/core/iomgr/udp_server.c
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -425,15 +425,5 @@ void grpc_udp_server_start(grpc_exec_ctx *exec_ctx, grpc_udp_server *s,
gpr_mu_unlock(&s->mu);
}
-/* TODO(rjshade): Add a test for this method. */
-void grpc_udp_server_write(server_port *sp, const char *buffer, size_t buf_len,
- const struct sockaddr *peer_address) {
- ssize_t rc;
- rc = sendto(sp->fd, buffer, buf_len, 0, peer_address, sizeof(peer_address));
- if (rc < 0) {
- gpr_log(GPR_ERROR, "Unable to send data: %s", strerror(errno));
- }
-}
-
#endif
#endif
diff --git a/src/core/iomgr/udp_server.h b/src/core/iomgr/udp_server.h
index de5736c426..73a21c80ab 100644
--- a/src/core/iomgr/udp_server.h
+++ b/src/core/iomgr/udp_server.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -72,12 +72,4 @@ int grpc_udp_server_add_port(grpc_udp_server *s, const void *addr,
void grpc_udp_server_destroy(grpc_exec_ctx *exec_ctx, grpc_udp_server *server,
grpc_closure *on_done);
-/* Write the contents of buffer to the underlying UDP socket. */
-/*
-void grpc_udp_server_write(grpc_udp_server *s,
- const char *buffer,
- int buf_len,
- const struct sockaddr* to);
- */
-
#endif /* GRPC_INTERNAL_CORE_IOMGR_UDP_SERVER_H */
diff --git a/src/core/support/env_win32.c b/src/core/support/env_win32.c
index 6b1ff102b0..10258283ba 100644
--- a/src/core/support/env_win32.c
+++ b/src/core/support/env_win32.c
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -38,7 +38,12 @@
#include "src/core/support/env.h"
#include "src/core/support/string.h"
+#ifdef __MINGW32__
+errno_t getenv_s(size_t *size_needed, char *buffer, size_t size,
+ const char *varname);
+#else
#include <stdlib.h>
+#endif
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
@@ -47,14 +52,17 @@
char *gpr_getenv(const char *name) {
size_t size;
char *result = NULL;
- char *duplicated;
errno_t err;
- err = _dupenv_s(&result, &size, name);
- if (err) return NULL;
- duplicated = gpr_strdup(result);
- free(result);
- return duplicated;
+ err = getenv_s(&size, NULL, 0, name);
+ if (err || (size == 0)) return NULL;
+ result = gpr_malloc(size);
+ err = getenv_s(&size, result, size, name);
+ if (err) {
+ gpr_free(result);
+ return NULL;
+ }
+ return result;
}
void gpr_setenv(const char *name, const char *value) {
diff --git a/src/core/support/log_win32.c b/src/core/support/log_win32.c
index 40adcd1b50..e18e667fe5 100644
--- a/src/core/support/log_win32.c
+++ b/src/core/support/log_win32.c
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -109,13 +109,13 @@ void gpr_default_log(gpr_log_func_args *args) {
fflush(stderr);
}
-char *gpr_format_message(DWORD messageid) {
+char *gpr_format_message(int messageid) {
LPTSTR tmessage;
char *message;
DWORD status = FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL, messageid, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ NULL, (DWORD)messageid, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR)(&tmessage), 0, NULL);
if (status == 0) return gpr_strdup("Unable to retrieve error string");
message = gpr_tchar_to_char(tmessage);
diff --git a/src/core/support/string_win32.c b/src/core/support/string_win32.c
index 914ba8771c..3b1f702cf1 100644
--- a/src/core/support/string_win32.c
+++ b/src/core/support/string_win32.c
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -85,8 +85,8 @@ LPTSTR
gpr_char_to_tchar(LPCSTR input) {
LPTSTR ret;
int needed = MultiByteToWideChar(CP_UTF8, 0, input, -1, NULL, 0);
- if (needed == 0) return NULL;
- ret = gpr_malloc(needed * sizeof(TCHAR));
+ if (needed <= 0) return NULL;
+ ret = gpr_malloc((unsigned)needed * sizeof(TCHAR));
MultiByteToWideChar(CP_UTF8, 0, input, -1, ret, needed);
return ret;
}
@@ -95,8 +95,8 @@ LPSTR
gpr_tchar_to_char(LPCTSTR input) {
LPSTR ret;
int needed = WideCharToMultiByte(CP_UTF8, 0, input, -1, NULL, 0, NULL, NULL);
- if (needed == 0) return NULL;
- ret = gpr_malloc(needed);
+ if (needed <= 0) return NULL;
+ ret = gpr_malloc((unsigned)needed);
WideCharToMultiByte(CP_UTF8, 0, input, -1, ret, needed, NULL, NULL);
return ret;
}
diff --git a/src/core/support/sync_win32.c b/src/core/support/sync_win32.c
index 51a082b29e..84d412a75f 100644
--- a/src/core/support/sync_win32.c
+++ b/src/core/support/sync_win32.c
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -94,7 +94,11 @@ int gpr_cv_wait(gpr_cv *cv, gpr_mu *mu, gpr_timespec abs_deadline) {
if (now_ms >= deadline_ms) {
timeout = 1;
} else {
- timeout_max_ms = (DWORD)min(deadline_ms - now_ms, INFINITE - 1);
+ if ((deadline_ms - now_ms) >= INFINITE) {
+ timeout_max_ms = INFINITE - 1;
+ } else {
+ timeout_max_ms = (DWORD)(deadline_ms - now_ms);
+ }
timeout = (SleepConditionVariableCS(cv, &mu->cs, timeout_max_ms) == 0 &&
GetLastError() == ERROR_TIMEOUT);
}
diff --git a/src/core/support/time_win32.c b/src/core/support/time_win32.c
index 2bed0f6a9c..8af957e6f4 100644
--- a/src/core/support/time_win32.c
+++ b/src/core/support/time_win32.c
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -37,9 +37,12 @@
#ifdef GPR_WIN32
+#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include <src/core/support/time_precise.h>
#include <sys/timeb.h>
+#include <process.h>
+#include <limits.h>
#include "src/core/support/block_annotate.h"
@@ -50,11 +53,12 @@ void gpr_time_init(void) {
LARGE_INTEGER frequency;
QueryPerformanceFrequency(&frequency);
QueryPerformanceCounter(&g_start_time);
- g_time_scale = 1.0 / frequency.QuadPart;
+ g_time_scale = 1.0 / (double)frequency.QuadPart;
}
gpr_timespec gpr_now(gpr_clock_type clock) {
gpr_timespec now_tv;
+ LONGLONG diff;
struct _timeb now_tb;
LARGE_INTEGER timestamp;
double now_dbl;
@@ -68,10 +72,14 @@ gpr_timespec gpr_now(gpr_clock_type clock) {
case GPR_CLOCK_MONOTONIC:
case GPR_CLOCK_PRECISE:
QueryPerformanceCounter(&timestamp);
- now_dbl = (timestamp.QuadPart - g_start_time.QuadPart) * g_time_scale;
+ diff = timestamp.QuadPart - g_start_time.QuadPart;
+ now_dbl = (double)diff * g_time_scale;
now_tv.tv_sec = (int64_t)now_dbl;
now_tv.tv_nsec = (int32_t)((now_dbl - (double)now_tv.tv_sec) * 1e9);
break;
+ case GPR_TIMESPAN:
+ abort();
+ break;
}
return now_tv;
}
@@ -79,7 +87,7 @@ gpr_timespec gpr_now(gpr_clock_type clock) {
void gpr_sleep_until(gpr_timespec until) {
gpr_timespec now;
gpr_timespec delta;
- DWORD sleep_millis;
+ int64_t sleep_millis;
for (;;) {
/* We could simplify by using clock_nanosleep instead, but it might be
@@ -91,9 +99,10 @@ void gpr_sleep_until(gpr_timespec until) {
delta = gpr_time_sub(until, now);
sleep_millis =
- (DWORD)delta.tv_sec * GPR_MS_PER_SEC + delta.tv_nsec / GPR_NS_PER_MS;
+ delta.tv_sec * GPR_MS_PER_SEC + delta.tv_nsec / GPR_NS_PER_MS;
+ GPR_ASSERT((sleep_millis >= 0) && (sleep_millis <= INT_MAX));
GRPC_SCHEDULING_START_BLOCKING_REGION;
- Sleep(sleep_millis);
+ Sleep((DWORD)sleep_millis);
GRPC_SCHEDULING_END_BLOCKING_REGION;
}
}
diff --git a/src/core/surface/server.c b/src/core/surface/server.c
index 79db13810a..0928f1e045 100644
--- a/src/core/surface/server.c
+++ b/src/core/surface/server.c
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -779,9 +779,7 @@ grpc_server *grpc_server_create_from_filters(
const grpc_channel_filter **filters, size_t filter_count,
const grpc_channel_args *args) {
size_t i;
- /* TODO(census): restore this once we finalize census filter etc.
- int census_enabled = grpc_channel_args_is_census_enabled(args); */
- int census_enabled = 0;
+ int census_enabled = grpc_channel_args_is_census_enabled(args);
grpc_server *server = gpr_malloc(sizeof(grpc_server));
diff --git a/src/core/surface/server_create.c b/src/core/surface/server_create.c
index f30093e06b..5e37e80948 100644
--- a/src/core/surface/server_create.c
+++ b/src/core/surface/server_create.c
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -43,9 +43,6 @@ grpc_server *grpc_server_create(const grpc_channel_args *args, void *reserved) {
const grpc_channel_filter *filters[3];
size_t num_filters = 0;
filters[num_filters++] = &grpc_compress_filter;
- if (grpc_channel_args_is_census_enabled(args)) {
- filters[num_filters++] = &grpc_server_census_filter;
- }
GRPC_API_TRACE("grpc_server_create(%p, %p)", 2, (args, reserved));
return grpc_server_create_from_filters(filters, num_filters, args);
}
diff --git a/src/proto/grpc/testing/echo_messages.proto b/src/proto/grpc/testing/echo_messages.proto
index f01d645af7..d05a35548d 100644
--- a/src/proto/grpc/testing/echo_messages.proto
+++ b/src/proto/grpc/testing/echo_messages.proto
@@ -1,5 +1,5 @@
-// Copyright 2015, Google Inc.
+// Copyright 2015-2016, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@@ -41,6 +41,7 @@ message RequestParams {
int32 response_message_length = 6;
bool echo_peer = 7;
string expected_client_identity = 8; // will force check_auth_context.
+ bool skip_cancelled_check = 9;
}
message EchoRequest {
diff --git a/src/python/grpcio/commands.py b/src/python/grpcio/commands.py
index 29b506abe0..a6b8ad3fc0 100644
--- a/src/python/grpcio/commands.py
+++ b/src/python/grpcio/commands.py
@@ -30,15 +30,22 @@
"""Provides distutils command classes for the GRPC Python setup process."""
import distutils
+import glob
import os
import os.path
+import platform
import re
+import shutil
import subprocess
import sys
+import traceback
import setuptools
+from setuptools.command import bdist_egg
from setuptools.command import build_ext
from setuptools.command import build_py
+from setuptools.command import easy_install
+from setuptools.command import install
from setuptools.command import test
import support
@@ -58,6 +65,129 @@ class CommandError(Exception):
"""Simple exception class for GRPC custom commands."""
+# TODO(atash): Remove this once PyPI has better Linux bdist support. See
+# https://bitbucket.org/pypa/pypi/issues/120/binary-wheels-for-linux-are-not-supported
+def _get_linux_bdist_egg(decorated_basename, target_egg_basename):
+ """Returns a string path to a .egg file for Linux to install.
+
+ If we can retrieve a pre-compiled egg from online, uses it. Else, emits a
+ warning and builds from source.
+ """
+ # Break import style to ensure that setup.py has had a chance to install the
+ # relevant package eggs.
+ from six.moves.urllib import request
+ decorated_path = decorated_basename + '.egg'
+ try:
+ url = (
+ 'https://storage.googleapis.com/grpc-precompiled-binaries/'
+ 'python/{target}'
+ .format(target=decorated_path))
+ egg_data = request.urlopen(url).read()
+ except IOError as error:
+ raise CommandError(
+ '{}\n\nCould not find the bdist egg {}: {}'
+ .format(traceback.format_exc(), decorated_path, error.message))
+ # Our chosen local egg path.
+ egg_path = target_egg_basename + '.egg'
+ try:
+ with open(egg_path, 'w') as egg_file:
+ egg_file.write(egg_data)
+ except IOError as error:
+ raise CommandError(
+ '{}\n\nCould not write grpcio egg: {}'
+ .format(traceback.format_exc(), error.message))
+ return egg_path
+
+
+class EggNameMixin(object):
+
+ def egg_name(self, with_custom):
+ """
+ Args:
+ with_custom: Boolean describing whether or not to decorate the egg name
+ with custom gRPC-specific target information.
+ """
+ egg_command = self.get_finalized_command('bdist_egg')
+ base = os.path.splitext(os.path.basename(egg_command.egg_output))[0]
+ if with_custom:
+ flavor = 'ucs2' if sys.maxunicode == 65535 else 'ucs4'
+ return '{base}-{flavor}'.format(base=base, flavor=flavor)
+ else:
+ return base
+
+
+class Install(install.install, EggNameMixin):
+ """Custom Install command for gRPC Python.
+
+ This is for bdist shims and whatever else we might need a custom install
+ command for.
+ """
+
+ user_options = install.install.user_options + [
+ # TODO(atash): remove this once manylinux gets on PyPI. See
+ # https://bitbucket.org/pypa/pypi/issues/120/binary-wheels-for-linux-are-not-supported
+ ('use-linux-bdist', None,
+ 'Whether to retrieve a binary for Linux instead of building from '
+ 'source.'),
+ ]
+
+ def initialize_options(self):
+ install.install.initialize_options(self)
+ self.use_linux_bdist = False
+
+ def finalize_options(self):
+ install.install.finalize_options(self)
+
+ def run(self):
+ if self.use_linux_bdist:
+ try:
+ egg_path = _get_linux_bdist_egg(self.egg_name(True),
+ self.egg_name(False))
+ except CommandError as error:
+ sys.stderr.write(
+ '\nWARNING: Failed to acquire grpcio prebuilt binary:\n'
+ '{}.\n\n'.format(error.message))
+ raise
+ try:
+ self._run_bdist_retrieval_install(egg_path)
+ except Exception as error:
+ # if anything else happens (and given how there's no way to really know
+ # what's happening in setuptools here, I mean *anything*), warn the user
+ # and fall back to building from source.
+ sys.stderr.write(
+ '{}\nWARNING: Failed to install grpcio prebuilt binary.\n\n'
+ .format(traceback.format_exc()))
+ install.install.run(self)
+ else:
+ install.install.run(self)
+
+ # TODO(atash): Remove this once PyPI has better Linux bdist support. See
+ # https://bitbucket.org/pypa/pypi/issues/120/binary-wheels-for-linux-are-not-supported
+ def _run_bdist_retrieval_install(self, bdist_egg):
+ easy_install = self.distribution.get_command_class('easy_install')
+ easy_install_command = easy_install(
+ self.distribution, args='x', root=self.root, record=self.record,
+ )
+ easy_install_command.ensure_finalized()
+ easy_install_command.always_copy_from = '.'
+ easy_install_command.package_index.scan(glob.glob('*.egg'))
+ arguments = [bdist_egg]
+ if setuptools.bootstrap_install_from:
+ args.insert(0, setuptools.bootstrap_install_from)
+ easy_install_command.args = arguments
+ easy_install_command.run()
+ setuptools.bootstrap_install_from = None
+
+
+class BdistEggCustomName(bdist_egg.bdist_egg, EggNameMixin):
+ """Thin wrapper around the bdist_egg command to build with our custom name."""
+
+ def run(self):
+ bdist_egg.bdist_egg.run(self)
+ target = os.path.join(self.dist_dir, '{}.egg'.format(self.egg_name(True)))
+ shutil.move(self.get_outputs()[0], target)
+
+
class SphinxDocumentation(setuptools.Command):
"""Command to generate documentation via sphinx."""
diff --git a/src/zlib/gen_build_yaml.py b/src/zlib/gen_build_yaml.py
index 8d6064b10a..4bd557367a 100755
--- a/src/zlib/gen_build_yaml.py
+++ b/src/zlib/gen_build_yaml.py
@@ -54,6 +54,7 @@ try:
out['libs'] = [{
'name': 'z',
'zlib': True,
+ 'defaults': 'zlib',
'build': 'private',
'language': 'c',
'secure': 'no',