Merge github.com:google/grpc into async-api-new

pull/381/head
Craig Tiller 10 years ago
commit 2ea1074bd9
  1. 2
      Makefile
  2. 2
      build.json
  3. 29
      include/grpc/support/time.h
  4. 43
      include/grpc/support/time_posix.h
  5. 46
      include/grpc/support/time_win32.h
  6. 2
      src/core/iomgr/resolve_address.c
  7. 2
      src/core/iomgr/socket_utils_linux.c
  8. 1
      src/core/iomgr/socket_utils_posix.c
  9. 6
      src/core/iomgr/tcp_server_posix.c
  10. 6
      src/core/support/log_linux.c
  11. 7
      src/core/support/log_posix.c
  12. 3
      src/core/support/string_posix.c
  13. 11
      src/core/support/sync_posix.c
  14. 16
      src/core/support/time.c
  15. 25
      src/core/support/time_posix.c
  16. 5
      src/core/surface/call.c
  17. 17
      src/core/transport/chttp2_transport.c
  18. 5
      src/node/ext/timeval.cc
  19. 3
      test/core/echo/echo_test.c
  20. 3
      test/core/fling/fling_stream_test.c
  21. 3
      test/core/fling/fling_test.c
  22. 3
      test/core/json/json_test.c
  23. 5
      tools/run_tests/run_tests.py
  24. 2
      tools/tsan_suppressions.txt
  25. 2
      vsprojects/vs2013/gpr.vcxproj
  26. 6
      vsprojects/vs2013/gpr.vcxproj.filters

@ -1670,8 +1670,6 @@ PUBLIC_HEADERS_C += \
include/grpc/support/sync_win32.h \
include/grpc/support/thd.h \
include/grpc/support/time.h \
include/grpc/support/time_posix.h \
include/grpc/support/time_win32.h \
include/grpc/support/useful.h \
LIBGPR_OBJS = $(addprefix objs/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBGPR_SRC))))

@ -225,8 +225,6 @@
"include/grpc/support/sync_win32.h",
"include/grpc/support/thd.h",
"include/grpc/support/time.h",
"include/grpc/support/time_posix.h",
"include/grpc/support/time_win32.h",
"include/grpc/support/useful.h"
],
"headers": [

@ -34,31 +34,22 @@
#ifndef __GRPC_SUPPORT_TIME_H__
#define __GRPC_SUPPORT_TIME_H__
/* Time support.
We use gpr_timespec, which is typedefed to struct timespec on platforms which
have it. On some machines, absolute times may be in local time. */
/* Platform specific header declares gpr_timespec.
gpr_timespec contains:
time_t tv_sec; // seconds since start of 1970
int tv_nsec; // nanoseconds; always in 0..999999999; never negative.
*/
We use gpr_timespec, which is analogous to struct timespec. On some
machines, absolute times may be in local time. */
#include <grpc/support/port_platform.h>
#if defined(GPR_POSIX_TIME)
#include <grpc/support/time_posix.h>
#elif defined(GPR_WIN32)
#include <grpc/support/time_win32.h>
#else
#error could not determine platform for time
#endif
#include <stddef.h>
#include <time.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct gpr_timespec {
time_t tv_sec;
int tv_nsec;
} gpr_timespec;
/* Time constants. */
extern const gpr_timespec gpr_time_0; /* The zero time interval. */
extern const gpr_timespec gpr_inf_future; /* The far future */
@ -103,10 +94,6 @@ int gpr_time_similar(gpr_timespec a, gpr_timespec b, gpr_timespec threshold);
/* Sleep until at least 'until' - an absolute timeout */
void gpr_sleep_until(gpr_timespec until);
struct timeval gpr_timeval_from_timespec(gpr_timespec t);
gpr_timespec gpr_timespec_from_timeval(struct timeval t);
double gpr_timespec_to_micros(gpr_timespec t);
#ifdef __cplusplus

@ -1,43 +0,0 @@
/*
*
* Copyright 2014, 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_TIME_POSIX_H__
#define __GRPC_SUPPORT_TIME_POSIX_H__
/* Posix variant of gpr_time_platform.h */
#include <sys/time.h>
#include <time.h>
typedef struct timespec gpr_timespec;
#endif /* __GRPC_SUPPORT_TIME_POSIX_H__ */

@ -1,46 +0,0 @@
/*
*
* Copyright 2014, 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_TIME_WIN32_H__
#define __GRPC_SUPPORT_TIME_WIN32_H__
/* Win32 variant of gpr_time_platform.h */
#include <Winsock.h>
#include <time.h>
typedef struct gpr_timespec {
time_t tv_sec;
long tv_nsec;
} gpr_timespec;
#endif /* __GRPC_SUPPORT_TIME_WIN32_H__ */

@ -31,7 +31,9 @@
*
*/
#ifndef _POSIX_SOURCE
#define _POSIX_SOURCE
#endif
#include "src/core/iomgr/sockaddr.h"
#include "src/core/iomgr/resolve_address.h"

@ -31,7 +31,9 @@
*
*/
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <grpc/support/port_platform.h>
#ifdef GPR_LINUX

@ -35,7 +35,6 @@
#ifdef GPR_POSIX_SOCKETUTILS
#define _BSD_SOURCE
#include "src/core/iomgr/socket_utils_posix.h"
#include <fcntl.h>

@ -31,11 +31,15 @@
*
*/
/* FIXME: "posix" files shouldn't be depending on _GNU_SOURCE */
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <grpc/support/port_platform.h>
#ifdef GPR_POSIX_SOCKET
#define _GNU_SOURCE
#include "src/core/iomgr/tcp_server.h"
#include <limits.h>

@ -31,8 +31,14 @@
*
*/
#ifndef _POSIX_SOURCE
#define _POSIX_SOURCE
#endif
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <grpc/support/port_platform.h>
#ifdef GPR_LINUX

@ -31,11 +31,16 @@
*
*/
#ifndef _POSIX_C_SOURCE
#if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 200112L
#undef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200112L
#endif
/* FIXME: "posix" files probably shouldn't depend on _GNU_SOURCE */
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <grpc/support/port_platform.h>
#if defined(GPR_POSIX_LOG)

@ -33,7 +33,8 @@
/* Posix code for gpr snprintf support. */
#ifndef _POSIX_C_SOURCE
#if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 200112L
#undef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200112L
#endif

@ -33,11 +33,17 @@
/* Posix gpr synchroization support code. */
#if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 199309L
#undef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 199309L
#endif
#include <grpc/support/port_platform.h>
#ifdef GPR_POSIX_SYNC
#include <errno.h>
#include <time.h>
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
#include <grpc/support/time.h>
@ -67,7 +73,10 @@ int gpr_cv_wait(gpr_cv *cv, gpr_mu *mu, gpr_timespec abs_deadline) {
if (gpr_time_cmp(abs_deadline, gpr_inf_future) == 0) {
err = pthread_cond_wait(cv, mu);
} else {
err = pthread_cond_timedwait(cv, mu, &abs_deadline);
struct timespec abs_deadline_ts;
abs_deadline_ts.tv_sec = abs_deadline.tv_sec;
abs_deadline_ts.tv_nsec = abs_deadline.tv_nsec;
err = pthread_cond_timedwait(cv, mu, &abs_deadline_ts);
}
GPR_ASSERT(err == 0 || err == ETIMEDOUT || err == EAGAIN);
return err == ETIMEDOUT;

@ -234,22 +234,6 @@ int gpr_time_similar(gpr_timespec a, gpr_timespec b, gpr_timespec threshold) {
}
}
struct timeval gpr_timeval_from_timespec(gpr_timespec t) {
/* TODO(klempner): Consider whether this should round up, since it is likely
to be used for delays */
struct timeval tv;
tv.tv_sec = t.tv_sec;
tv.tv_usec = t.tv_nsec / 1000;
return tv;
}
gpr_timespec gpr_timespec_from_timeval(struct timeval t) {
gpr_timespec ts;
ts.tv_sec = t.tv_sec;
ts.tv_nsec = t.tv_usec * 1000;
return ts;
}
gpr_int32 gpr_time_to_millis(gpr_timespec t) {
if (t.tv_sec >= 2147483) {
if (t.tv_sec == 2147483 && t.tv_nsec < 648 * GPR_NS_PER_MS) {

@ -34,7 +34,8 @@
/* Posix code for gpr time support. */
/* So we get nanosleep and clock_* */
#ifndef _POSIX_C_SOURCE
#if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 199309L
#undef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 199309L
#endif
@ -47,11 +48,25 @@
#include <unistd.h>
#include <grpc/support/time.h>
static struct timespec timespec_from_gpr(gpr_timespec gts) {
struct timespec rv;
rv.tv_sec = gts.tv_sec;
rv.tv_nsec = gts.tv_nsec;
return rv;
}
#if _POSIX_TIMERS > 0
static gpr_timespec gpr_from_timespec(struct timespec ts) {
gpr_timespec rv;
rv.tv_sec = ts.tv_sec;
rv.tv_nsec = ts.tv_nsec;
return rv;
}
gpr_timespec gpr_now(void) {
gpr_timespec now;
struct timespec now;
clock_gettime(CLOCK_REALTIME, &now);
return now;
return gpr_from_timespec(now);
}
#else
/* For some reason Apple's OSes haven't implemented clock_gettime. */
@ -69,6 +84,7 @@ gpr_timespec gpr_now(void) {
void gpr_sleep_until(gpr_timespec until) {
gpr_timespec now;
gpr_timespec delta;
struct timespec delta_ts;
for (;;) {
/* We could simplify by using clock_nanosleep instead, but it might be
@ -79,7 +95,8 @@ void gpr_sleep_until(gpr_timespec until) {
}
delta = gpr_time_sub(until, now);
if (nanosleep(&delta, NULL) == 0) {
delta_ts = timespec_from_gpr(delta);
if (nanosleep(&delta_ts, NULL) == 0) {
break;
}
}

@ -163,11 +163,12 @@ struct grpc_call {
a request, and is valid iff request_set[op] <= GRPC_IOREQ_OP_COUNT.
The set fields are as per the request type specified by op.
Finally, one element of masters[op] is set per active _group_ of ioreq
Finally, one element of masters is set per active _set_ of ioreq
operations. It describes work left outstanding, result status, and
what work to perform upon operation completion. As one ioreq of each
op type can be active at once, by convention we choose the first element
of a the group to be the master. This allows constant time allocation
of the group to be the master -- ie the master of in-progress operation
op is masters[request_set[op]]. This allows constant time allocation
and a strong upper bound of a count of masters to be calculated. */
gpr_uint8 request_set[GRPC_IOREQ_OP_COUNT];
grpc_ioreq_data request_data[GRPC_IOREQ_OP_COUNT];

@ -328,6 +328,9 @@ static void maybe_start_some_streams(transport *t);
static void become_skip_parser(transport *t);
static void recv_data(void *tp, gpr_slice *slices, size_t nslices,
grpc_endpoint_cb_status error);
/*
* CONSTRUCTION/DESTRUCTION/REFCOUNTING
*/
@ -382,8 +385,8 @@ static void ref_transport(transport *t) { gpr_ref(&t->refs); }
static void init_transport(transport *t, grpc_transport_setup_callback setup,
void *arg, const grpc_channel_args *channel_args,
grpc_endpoint *ep, grpc_mdctx *mdctx,
int is_client) {
grpc_endpoint *ep, gpr_slice *slices, size_t nslices,
grpc_mdctx *mdctx, int is_client) {
size_t i;
int j;
grpc_transport_setup_result sr;
@ -422,6 +425,7 @@ static void init_transport(transport *t, grpc_transport_setup_callback setup,
gpr_slice_buffer_init(&t->outbuf);
gpr_slice_buffer_init(&t->qbuf);
grpc_sopb_init(&t->nuke_later_sopb);
grpc_chttp2_hpack_parser_init(&t->hpack_parser, t->metadata_context);
if (is_client) {
gpr_slice_buffer_add(&t->qbuf,
gpr_slice_from_copied_string(CLIENT_CONNECT_STRING));
@ -476,12 +480,14 @@ static void init_transport(transport *t, grpc_transport_setup_callback setup,
ref_transport(t);
gpr_mu_unlock(&t->mu);
ref_transport(t);
recv_data(t, slices, nslices, GRPC_ENDPOINT_CB_OK);
sr = setup(arg, &t->base, t->metadata_context);
lock(t);
t->cb = sr.callbacks;
t->cb_user_data = sr.user_data;
grpc_chttp2_hpack_parser_init(&t->hpack_parser, t->metadata_context);
t->calling_back = 0;
gpr_cv_broadcast(&t->cv);
unlock(t);
@ -1769,7 +1775,6 @@ void grpc_create_chttp2_transport(grpc_transport_setup_callback setup,
size_t nslices, grpc_mdctx *mdctx,
int is_client) {
transport *t = gpr_malloc(sizeof(transport));
init_transport(t, setup, arg, channel_args, ep, mdctx, is_client);
ref_transport(t);
recv_data(t, slices, nslices, GRPC_ENDPOINT_CB_OK);
init_transport(t, setup, arg, channel_args, ep, slices, nslices, mdctx,
is_client);
}

@ -56,9 +56,8 @@ double TimespecToMilliseconds(gpr_timespec timespec) {
} else if (gpr_time_cmp(timespec, gpr_inf_past) == 0) {
return -std::numeric_limits<double>::infinity();
} else {
struct timeval time = gpr_timeval_from_timespec(timespec);
return (static_cast<double>(time.tv_sec) * 1000 +
static_cast<double>(time.tv_usec) / 1000);
return (static_cast<double>(timespec.tv_sec) * 1000 +
static_cast<double>(timespec.tv_nsec) / 1000000);
}
}

@ -31,7 +31,10 @@
*
*/
#ifndef _POSIX_SOURCE
#define _POSIX_SOURCE
#endif
#include <unistd.h>
#include <assert.h>
#include <stdio.h>

@ -31,7 +31,10 @@
*
*/
#ifndef _POSIX_SOURCE
#define _POSIX_SOURCE
#endif
#include <unistd.h>
#include <assert.h>
#include <stdio.h>

@ -31,7 +31,10 @@
*
*/
#ifndef _POSIX_SOURCE
#define _POSIX_SOURCE
#endif
#include <unistd.h>
#include <assert.h>
#include <stdio.h>

@ -151,7 +151,7 @@ static void test_pairs() {
GPR_ASSERT(!json);
}
free(scratchpad);
gpr_free(scratchpad);
}
}
@ -166,6 +166,7 @@ static void test_atypical() {
grpc_json_destroy(json->child);
json->child = brother;
grpc_json_destroy(json);
gpr_free(scratchpad);
}
int main(int argc, char **argv) {

@ -108,10 +108,11 @@ class PythonLanguage(object):
_CONFIGS = {
'dbg': SimpleConfig('dbg'),
'opt': SimpleConfig('opt'),
'tsan': SimpleConfig('tsan'),
'tsan': SimpleConfig('tsan', environ={
'TSAN_OPTIONS': 'suppressions=tools/tsan_suppressions.txt'}),
'msan': SimpleConfig('msan'),
'asan': SimpleConfig('asan', environ={
'ASAN_OPTIONS': 'detect_leaks=1:color=always'}),
'ASAN_OPTIONS': 'detect_leaks=1:color=always:suppressions=tools/tsan_suppressions.txt'}),
'gcov': SimpleConfig('gcov'),
'memcheck': ValgrindConfig('valgrind', 'memcheck'),
'helgrind': ValgrindConfig('dbg', 'helgrind')

@ -0,0 +1,2 @@
# OPENSSL_cleanse does racy access to a global
race:OPENSSL_cleanse

@ -92,8 +92,6 @@
<ClInclude Include="..\..\include\grpc\support\sync_win32.h" />
<ClInclude Include="..\..\include\grpc\support\thd.h" />
<ClInclude Include="..\..\include\grpc\support\time.h" />
<ClInclude Include="..\..\include\grpc\support\time_posix.h" />
<ClInclude Include="..\..\include\grpc\support\time_win32.h" />
<ClInclude Include="..\..\include\grpc\support\useful.h" />
</ItemGroup>
<ItemGroup>

@ -138,12 +138,6 @@
<ClInclude Include="..\..\include\grpc\support\time.h">
<Filter>include\grpc\support</Filter>
</ClInclude>
<ClInclude Include="..\..\include\grpc\support\time_posix.h">
<Filter>include\grpc\support</Filter>
</ClInclude>
<ClInclude Include="..\..\include\grpc\support\time_win32.h">
<Filter>include\grpc\support</Filter>
</ClInclude>
<ClInclude Include="..\..\include\grpc\support\useful.h">
<Filter>include\grpc\support</Filter>
</ClInclude>

Loading…
Cancel
Save