diff options
author | David Garcia Quintas <dgq@google.com> | 2016-01-28 11:01:47 -0800 |
---|---|---|
committer | David Garcia Quintas <dgq@google.com> | 2016-01-28 11:01:47 -0800 |
commit | dcc99a24eab23e42b63593c9a45e0e7e1392c49b (patch) | |
tree | c5db732fb88e8527acd670264569bd6e420a80c3 /src | |
parent | d79ef3af71862f45fdb2b49b8427d403f2df0727 (diff) | |
parent | 9fad88fecf1e0669b5b428beb2d67f25e3147a11 (diff) |
Merge branch 'master' of github.com:grpc/grpc into sync-async-plus-interfaces
Diffstat (limited to 'src')
-rwxr-xr-x | src/boringssl/gen_build_yaml.py | 5 | ||||
-rw-r--r-- | src/core/channel/channel_args.c | 7 | ||||
-rw-r--r-- | src/core/iomgr/iocp_windows.c | 6 | ||||
-rw-r--r-- | src/core/iomgr/pollset_windows.c | 11 | ||||
-rw-r--r-- | src/core/iomgr/sockaddr_win32.h | 7 | ||||
-rw-r--r-- | src/core/iomgr/tcp_server_windows.c | 2 | ||||
-rw-r--r-- | src/core/iomgr/tcp_windows.c | 6 | ||||
-rw-r--r-- | src/core/iomgr/udp_server.c | 12 | ||||
-rw-r--r-- | src/core/iomgr/udp_server.h | 10 | ||||
-rw-r--r-- | src/core/support/env_win32.c | 22 | ||||
-rw-r--r-- | src/core/support/log_win32.c | 6 | ||||
-rw-r--r-- | src/core/support/string_win32.c | 10 | ||||
-rw-r--r-- | src/core/support/sync_win32.c | 8 | ||||
-rw-r--r-- | src/core/support/time_win32.c | 21 | ||||
-rw-r--r-- | src/core/surface/server.c | 6 | ||||
-rw-r--r-- | src/core/surface/server_create.c | 5 | ||||
-rwxr-xr-x | src/zlib/gen_build_yaml.py | 1 |
17 files changed, 65 insertions, 80 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/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(×tamp); - 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/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', |