Merge pull request #5456 from ctiller/cleaner-posix3
Splitting out a pure poll() based event engine
This commit is contained in:
commit
effd74c3cc
6
BUILD
6
BUILD
|
|
@ -179,6 +179,7 @@ cc_library(
|
|||
"src/core/lib/iomgr/endpoint.h",
|
||||
"src/core/lib/iomgr/endpoint_pair.h",
|
||||
"src/core/lib/iomgr/ev_poll_and_epoll_posix.h",
|
||||
"src/core/lib/iomgr/ev_poll_posix.h",
|
||||
"src/core/lib/iomgr/ev_posix.h",
|
||||
"src/core/lib/iomgr/exec_ctx.h",
|
||||
"src/core/lib/iomgr/executor.h",
|
||||
|
|
@ -313,6 +314,7 @@ cc_library(
|
|||
"src/core/lib/iomgr/endpoint_pair_posix.c",
|
||||
"src/core/lib/iomgr/endpoint_pair_windows.c",
|
||||
"src/core/lib/iomgr/ev_poll_and_epoll_posix.c",
|
||||
"src/core/lib/iomgr/ev_poll_posix.c",
|
||||
"src/core/lib/iomgr/ev_posix.c",
|
||||
"src/core/lib/iomgr/exec_ctx.c",
|
||||
"src/core/lib/iomgr/executor.c",
|
||||
|
|
@ -530,6 +532,7 @@ cc_library(
|
|||
"src/core/lib/iomgr/endpoint.h",
|
||||
"src/core/lib/iomgr/endpoint_pair.h",
|
||||
"src/core/lib/iomgr/ev_poll_and_epoll_posix.h",
|
||||
"src/core/lib/iomgr/ev_poll_posix.h",
|
||||
"src/core/lib/iomgr/ev_posix.h",
|
||||
"src/core/lib/iomgr/exec_ctx.h",
|
||||
"src/core/lib/iomgr/executor.h",
|
||||
|
|
@ -650,6 +653,7 @@ cc_library(
|
|||
"src/core/lib/iomgr/endpoint_pair_posix.c",
|
||||
"src/core/lib/iomgr/endpoint_pair_windows.c",
|
||||
"src/core/lib/iomgr/ev_poll_and_epoll_posix.c",
|
||||
"src/core/lib/iomgr/ev_poll_posix.c",
|
||||
"src/core/lib/iomgr/ev_posix.c",
|
||||
"src/core/lib/iomgr/exec_ctx.c",
|
||||
"src/core/lib/iomgr/executor.c",
|
||||
|
|
@ -1342,6 +1346,7 @@ objc_library(
|
|||
"src/core/lib/iomgr/endpoint_pair_posix.c",
|
||||
"src/core/lib/iomgr/endpoint_pair_windows.c",
|
||||
"src/core/lib/iomgr/ev_poll_and_epoll_posix.c",
|
||||
"src/core/lib/iomgr/ev_poll_posix.c",
|
||||
"src/core/lib/iomgr/ev_posix.c",
|
||||
"src/core/lib/iomgr/exec_ctx.c",
|
||||
"src/core/lib/iomgr/executor.c",
|
||||
|
|
@ -1538,6 +1543,7 @@ objc_library(
|
|||
"src/core/lib/iomgr/endpoint.h",
|
||||
"src/core/lib/iomgr/endpoint_pair.h",
|
||||
"src/core/lib/iomgr/ev_poll_and_epoll_posix.h",
|
||||
"src/core/lib/iomgr/ev_poll_posix.h",
|
||||
"src/core/lib/iomgr/ev_posix.h",
|
||||
"src/core/lib/iomgr/exec_ctx.h",
|
||||
"src/core/lib/iomgr/executor.h",
|
||||
|
|
|
|||
2
Makefile
2
Makefile
|
|
@ -2511,6 +2511,7 @@ LIBGRPC_SRC = \
|
|||
src/core/lib/iomgr/endpoint_pair_posix.c \
|
||||
src/core/lib/iomgr/endpoint_pair_windows.c \
|
||||
src/core/lib/iomgr/ev_poll_and_epoll_posix.c \
|
||||
src/core/lib/iomgr/ev_poll_posix.c \
|
||||
src/core/lib/iomgr/ev_posix.c \
|
||||
src/core/lib/iomgr/exec_ctx.c \
|
||||
src/core/lib/iomgr/executor.c \
|
||||
|
|
@ -2857,6 +2858,7 @@ LIBGRPC_UNSECURE_SRC = \
|
|||
src/core/lib/iomgr/endpoint_pair_posix.c \
|
||||
src/core/lib/iomgr/endpoint_pair_windows.c \
|
||||
src/core/lib/iomgr/ev_poll_and_epoll_posix.c \
|
||||
src/core/lib/iomgr/ev_poll_posix.c \
|
||||
src/core/lib/iomgr/ev_posix.c \
|
||||
src/core/lib/iomgr/exec_ctx.c \
|
||||
src/core/lib/iomgr/executor.c \
|
||||
|
|
|
|||
|
|
@ -582,6 +582,7 @@
|
|||
'src/core/lib/iomgr/endpoint_pair_posix.c',
|
||||
'src/core/lib/iomgr/endpoint_pair_windows.c',
|
||||
'src/core/lib/iomgr/ev_poll_and_epoll_posix.c',
|
||||
'src/core/lib/iomgr/ev_poll_posix.c',
|
||||
'src/core/lib/iomgr/ev_posix.c',
|
||||
'src/core/lib/iomgr/exec_ctx.c',
|
||||
'src/core/lib/iomgr/executor.c',
|
||||
|
|
|
|||
|
|
@ -166,6 +166,7 @@ filegroups:
|
|||
- src/core/lib/iomgr/endpoint.h
|
||||
- src/core/lib/iomgr/endpoint_pair.h
|
||||
- src/core/lib/iomgr/ev_poll_and_epoll_posix.h
|
||||
- src/core/lib/iomgr/ev_poll_posix.h
|
||||
- src/core/lib/iomgr/ev_posix.h
|
||||
- src/core/lib/iomgr/exec_ctx.h
|
||||
- src/core/lib/iomgr/executor.h
|
||||
|
|
@ -240,6 +241,7 @@ filegroups:
|
|||
- src/core/lib/iomgr/endpoint_pair_posix.c
|
||||
- src/core/lib/iomgr/endpoint_pair_windows.c
|
||||
- src/core/lib/iomgr/ev_poll_and_epoll_posix.c
|
||||
- src/core/lib/iomgr/ev_poll_posix.c
|
||||
- src/core/lib/iomgr/ev_posix.c
|
||||
- src/core/lib/iomgr/exec_ctx.c
|
||||
- src/core/lib/iomgr/executor.c
|
||||
|
|
|
|||
|
|
@ -101,6 +101,7 @@ if test "$PHP_GRPC" != "no"; then
|
|||
src/core/lib/iomgr/endpoint_pair_posix.c \
|
||||
src/core/lib/iomgr/endpoint_pair_windows.c \
|
||||
src/core/lib/iomgr/ev_poll_and_epoll_posix.c \
|
||||
src/core/lib/iomgr/ev_poll_posix.c \
|
||||
src/core/lib/iomgr/ev_posix.c \
|
||||
src/core/lib/iomgr/exec_ctx.c \
|
||||
src/core/lib/iomgr/executor.c \
|
||||
|
|
|
|||
|
|
@ -182,6 +182,7 @@ Pod::Spec.new do |s|
|
|||
'src/core/lib/iomgr/endpoint.h',
|
||||
'src/core/lib/iomgr/endpoint_pair.h',
|
||||
'src/core/lib/iomgr/ev_poll_and_epoll_posix.h',
|
||||
'src/core/lib/iomgr/ev_poll_posix.h',
|
||||
'src/core/lib/iomgr/ev_posix.h',
|
||||
'src/core/lib/iomgr/exec_ctx.h',
|
||||
'src/core/lib/iomgr/executor.h',
|
||||
|
|
@ -350,6 +351,7 @@ Pod::Spec.new do |s|
|
|||
'src/core/lib/iomgr/endpoint_pair_posix.c',
|
||||
'src/core/lib/iomgr/endpoint_pair_windows.c',
|
||||
'src/core/lib/iomgr/ev_poll_and_epoll_posix.c',
|
||||
'src/core/lib/iomgr/ev_poll_posix.c',
|
||||
'src/core/lib/iomgr/ev_posix.c',
|
||||
'src/core/lib/iomgr/exec_ctx.c',
|
||||
'src/core/lib/iomgr/executor.c',
|
||||
|
|
@ -530,6 +532,7 @@ Pod::Spec.new do |s|
|
|||
'src/core/lib/iomgr/endpoint.h',
|
||||
'src/core/lib/iomgr/endpoint_pair.h',
|
||||
'src/core/lib/iomgr/ev_poll_and_epoll_posix.h',
|
||||
'src/core/lib/iomgr/ev_poll_posix.h',
|
||||
'src/core/lib/iomgr/ev_posix.h',
|
||||
'src/core/lib/iomgr/exec_ctx.h',
|
||||
'src/core/lib/iomgr/executor.h',
|
||||
|
|
|
|||
|
|
@ -191,6 +191,7 @@ Gem::Specification.new do |s|
|
|||
s.files += %w( src/core/lib/iomgr/endpoint.h )
|
||||
s.files += %w( src/core/lib/iomgr/endpoint_pair.h )
|
||||
s.files += %w( src/core/lib/iomgr/ev_poll_and_epoll_posix.h )
|
||||
s.files += %w( src/core/lib/iomgr/ev_poll_posix.h )
|
||||
s.files += %w( src/core/lib/iomgr/ev_posix.h )
|
||||
s.files += %w( src/core/lib/iomgr/exec_ctx.h )
|
||||
s.files += %w( src/core/lib/iomgr/executor.h )
|
||||
|
|
@ -329,6 +330,7 @@ Gem::Specification.new do |s|
|
|||
s.files += %w( src/core/lib/iomgr/endpoint_pair_posix.c )
|
||||
s.files += %w( src/core/lib/iomgr/endpoint_pair_windows.c )
|
||||
s.files += %w( src/core/lib/iomgr/ev_poll_and_epoll_posix.c )
|
||||
s.files += %w( src/core/lib/iomgr/ev_poll_posix.c )
|
||||
s.files += %w( src/core/lib/iomgr/ev_posix.c )
|
||||
s.files += %w( src/core/lib/iomgr/exec_ctx.c )
|
||||
s.files += %w( src/core/lib/iomgr/executor.c )
|
||||
|
|
|
|||
|
|
@ -198,6 +198,7 @@
|
|||
<file baseinstalldir="/" name="src/core/lib/iomgr/endpoint.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/lib/iomgr/endpoint_pair.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/lib/iomgr/ev_poll_and_epoll_posix.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/lib/iomgr/ev_poll_posix.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/lib/iomgr/ev_posix.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/lib/iomgr/exec_ctx.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/lib/iomgr/executor.h" role="src" />
|
||||
|
|
@ -336,6 +337,7 @@
|
|||
<file baseinstalldir="/" name="src/core/lib/iomgr/endpoint_pair_posix.c" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/lib/iomgr/endpoint_pair_windows.c" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/lib/iomgr/ev_poll_and_epoll_posix.c" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/lib/iomgr/ev_poll_posix.c" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/lib/iomgr/ev_posix.c" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/lib/iomgr/exec_ctx.c" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/lib/iomgr/executor.c" role="src" />
|
||||
|
|
|
|||
|
|
@ -790,7 +790,6 @@ static void pollset_kick(grpc_pollset *p,
|
|||
static void pollset_global_init(void) {
|
||||
gpr_tls_init(&g_current_thread_poller);
|
||||
gpr_tls_init(&g_current_thread_worker);
|
||||
grpc_wakeup_fd_global_init();
|
||||
grpc_wakeup_fd_init(&grpc_global_wakeup_fd);
|
||||
}
|
||||
|
||||
|
|
@ -798,7 +797,6 @@ static void pollset_global_shutdown(void) {
|
|||
grpc_wakeup_fd_destroy(&grpc_global_wakeup_fd);
|
||||
gpr_tls_destroy(&g_current_thread_poller);
|
||||
gpr_tls_destroy(&g_current_thread_worker);
|
||||
grpc_wakeup_fd_global_destroy();
|
||||
}
|
||||
|
||||
static void kick_poller(void) { grpc_wakeup_fd_wakeup(&grpc_global_wakeup_fd); }
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
*
|
||||
* Copyright 2015-2016, 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_CORE_LIB_IOMGR_EV_POLL_POSIX_H
|
||||
#define GRPC_CORE_LIB_IOMGR_EV_POLL_POSIX_H
|
||||
|
||||
#include "src/core/lib/iomgr/ev_posix.h"
|
||||
|
||||
const grpc_event_engine_vtable *grpc_init_poll_posix(void);
|
||||
|
||||
#endif /* GRPC_CORE_LIB_IOMGR_EV_POLL_POSIX_H */
|
||||
|
|
@ -37,23 +37,104 @@
|
|||
|
||||
#include "src/core/lib/iomgr/ev_posix.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <grpc/support/alloc.h>
|
||||
#include <grpc/support/log.h>
|
||||
#include <grpc/support/string_util.h>
|
||||
#include <grpc/support/useful.h>
|
||||
|
||||
#include "src/core/lib/iomgr/ev_poll_and_epoll_posix.h"
|
||||
#include "src/core/lib/iomgr/ev_poll_posix.h"
|
||||
#include "src/core/lib/support/env.h"
|
||||
|
||||
/** Default poll() function - a pointer so that it can be overridden by some
|
||||
* tests */
|
||||
grpc_poll_function_type grpc_poll_function = poll;
|
||||
|
||||
static const grpc_event_engine_vtable *g_event_engine;
|
||||
|
||||
grpc_poll_function_type grpc_poll_function = poll;
|
||||
typedef const grpc_event_engine_vtable *(*event_engine_factory_fn)(void);
|
||||
|
||||
void grpc_event_engine_init(void) {
|
||||
if ((g_event_engine = grpc_init_poll_and_epoll_posix())) {
|
||||
return;
|
||||
}
|
||||
gpr_log(GPR_ERROR, "No event engine could be initialized");
|
||||
abort();
|
||||
typedef struct {
|
||||
const char *name;
|
||||
event_engine_factory_fn factory;
|
||||
} event_engine_factory;
|
||||
|
||||
static const event_engine_factory g_factories[] = {
|
||||
{"poll", grpc_init_poll_posix}, {"legacy", grpc_init_poll_and_epoll_posix},
|
||||
};
|
||||
|
||||
static void add(const char *beg, const char *end, char ***ss, size_t *ns) {
|
||||
size_t n = *ns;
|
||||
size_t np = n + 1;
|
||||
char *s;
|
||||
size_t len;
|
||||
GPR_ASSERT(end >= beg);
|
||||
len = (size_t)(end - beg);
|
||||
s = gpr_malloc(len + 1);
|
||||
memcpy(s, beg, len);
|
||||
s[len] = 0;
|
||||
*ss = gpr_realloc(*ss, sizeof(char **) * np);
|
||||
(*ss)[n] = s;
|
||||
*ns = np;
|
||||
}
|
||||
|
||||
void grpc_event_engine_shutdown(void) { g_event_engine->shutdown_engine(); }
|
||||
static void split(const char *s, char ***ss, size_t *ns) {
|
||||
const char *c = strchr(s, ',');
|
||||
if (c == NULL) {
|
||||
add(s, s + strlen(s), ss, ns);
|
||||
} else {
|
||||
add(s, c, ss, ns);
|
||||
split(c + 1, ss, ns);
|
||||
}
|
||||
}
|
||||
|
||||
static bool is(const char *want, const char *have) {
|
||||
return 0 == strcmp(want, "all") || 0 == strcmp(want, have);
|
||||
}
|
||||
|
||||
static void try_engine(const char *engine) {
|
||||
for (size_t i = 0; i < GPR_ARRAY_SIZE(g_factories); i++) {
|
||||
if (is(engine, g_factories[i].name)) {
|
||||
if ((g_event_engine = g_factories[i].factory())) {
|
||||
gpr_log(GPR_DEBUG, "Using polling engine: %s", g_factories[i].name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void grpc_event_engine_init(void) {
|
||||
char *s = gpr_getenv("GRPC_POLL_STRATEGY");
|
||||
if (s == NULL) {
|
||||
s = gpr_strdup("all");
|
||||
}
|
||||
|
||||
char **strings = NULL;
|
||||
size_t nstrings = 0;
|
||||
split(s, &strings, &nstrings);
|
||||
|
||||
for (size_t i = 0; g_event_engine == NULL && i < nstrings; i++) {
|
||||
try_engine(strings[i]);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < nstrings; i++) {
|
||||
gpr_free(strings[i]);
|
||||
}
|
||||
gpr_free(strings);
|
||||
gpr_free(s);
|
||||
|
||||
if (g_event_engine == NULL) {
|
||||
gpr_log(GPR_ERROR, "No event engine could be initialized");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
void grpc_event_engine_shutdown(void) {
|
||||
g_event_engine->shutdown_engine();
|
||||
g_event_engine = NULL;
|
||||
}
|
||||
|
||||
grpc_fd *grpc_fd_create(int fd, const char *name) {
|
||||
return g_event_engine->fd_create(fd, name);
|
||||
|
|
|
|||
|
|
@ -41,12 +41,16 @@
|
|||
#include "src/core/lib/iomgr/tcp_posix.h"
|
||||
|
||||
void grpc_iomgr_platform_init(void) {
|
||||
grpc_wakeup_fd_global_init();
|
||||
grpc_event_engine_init();
|
||||
grpc_register_tracer("tcp", &grpc_tcp_trace);
|
||||
}
|
||||
|
||||
void grpc_iomgr_platform_flush(void) {}
|
||||
|
||||
void grpc_iomgr_platform_shutdown(void) { grpc_event_engine_shutdown(); }
|
||||
void grpc_iomgr_platform_shutdown(void) {
|
||||
grpc_event_engine_shutdown();
|
||||
grpc_wakeup_fd_global_destroy();
|
||||
}
|
||||
|
||||
#endif /* GRPC_POSIX_SOCKET */
|
||||
|
|
|
|||
|
|
@ -95,6 +95,7 @@ CORE_SOURCE_FILES = [
|
|||
'src/core/lib/iomgr/endpoint_pair_posix.c',
|
||||
'src/core/lib/iomgr/endpoint_pair_windows.c',
|
||||
'src/core/lib/iomgr/ev_poll_and_epoll_posix.c',
|
||||
'src/core/lib/iomgr/ev_poll_posix.c',
|
||||
'src/core/lib/iomgr/ev_posix.c',
|
||||
'src/core/lib/iomgr/exec_ctx.c',
|
||||
'src/core/lib/iomgr/executor.c',
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@
|
|||
#include <grpc/support/host_port.h>
|
||||
#include <grpc/support/log.h>
|
||||
#include <grpc/support/slice.h>
|
||||
#include <grpc/support/thd.h>
|
||||
|
||||
#include "src/core/ext/client_config/initial_connect_string.h"
|
||||
#include "src/core/lib/iomgr/sockaddr.h"
|
||||
|
|
@ -56,7 +57,7 @@ struct rpc_state {
|
|||
gpr_slice_buffer incoming_buffer;
|
||||
gpr_slice_buffer temp_incoming_buffer;
|
||||
grpc_endpoint *tcp;
|
||||
int done;
|
||||
gpr_atm done_atm;
|
||||
};
|
||||
|
||||
static const char *magic_connect_string = "magic initial string";
|
||||
|
|
@ -69,7 +70,7 @@ static void handle_read(grpc_exec_ctx *exec_ctx, void *arg, bool success) {
|
|||
gpr_slice_buffer_move_into(&state.temp_incoming_buffer,
|
||||
&state.incoming_buffer);
|
||||
if (state.incoming_buffer.length > strlen(magic_connect_string)) {
|
||||
state.done = 1;
|
||||
gpr_atm_rel_store(&state.done_atm, 1);
|
||||
grpc_endpoint_shutdown(exec_ctx, state.tcp);
|
||||
grpc_endpoint_destroy(exec_ctx, state.tcp);
|
||||
} else {
|
||||
|
|
@ -116,7 +117,7 @@ static gpr_timespec n_sec_deadline(int seconds) {
|
|||
}
|
||||
|
||||
static void start_rpc(int use_creds, int target_port) {
|
||||
state.done = 0;
|
||||
gpr_atm_rel_store(&state.done_atm, 0);
|
||||
state.cq = grpc_completion_queue_create(NULL);
|
||||
if (use_creds) {
|
||||
state.creds = grpc_fake_transport_security_credentials_create();
|
||||
|
|
@ -139,7 +140,7 @@ static void start_rpc(int use_creds, int target_port) {
|
|||
state.op.reserved = NULL;
|
||||
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(state.call, &state.op,
|
||||
(size_t)(1), NULL, NULL));
|
||||
grpc_completion_queue_next(state.cq, n_sec_deadline(1), NULL);
|
||||
grpc_completion_queue_next(state.cq, n_sec_deadline(5), NULL);
|
||||
}
|
||||
|
||||
static void cleanup_rpc(void) {
|
||||
|
|
@ -157,12 +158,29 @@ static void cleanup_rpc(void) {
|
|||
gpr_free(state.target);
|
||||
}
|
||||
|
||||
static void poll_server_until_read_done(test_tcp_server *server) {
|
||||
gpr_timespec deadline = n_sec_deadline(5);
|
||||
while (state.done == 0 &&
|
||||
typedef struct {
|
||||
test_tcp_server *server;
|
||||
gpr_event *signal_when_done;
|
||||
} poll_args;
|
||||
|
||||
static void actually_poll_server(void *arg) {
|
||||
poll_args *pa = arg;
|
||||
gpr_timespec deadline = n_sec_deadline(10);
|
||||
while (gpr_atm_acq_load(&state.done_atm) == 0 &&
|
||||
gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), deadline) < 0) {
|
||||
test_tcp_server_poll(server, 1);
|
||||
test_tcp_server_poll(pa->server, 1);
|
||||
}
|
||||
gpr_event_set(pa->signal_when_done, (void *)1);
|
||||
gpr_free(pa);
|
||||
}
|
||||
|
||||
static void poll_server_until_read_done(test_tcp_server *server,
|
||||
gpr_event *signal_when_done) {
|
||||
gpr_thd_id id;
|
||||
poll_args *pa = gpr_malloc(sizeof(*pa));
|
||||
pa->server = server;
|
||||
pa->signal_when_done = signal_when_done;
|
||||
gpr_thd_new(&id, actually_poll_server, pa, NULL);
|
||||
}
|
||||
|
||||
static void match_initial_magic_string(gpr_slice_buffer *buffer) {
|
||||
|
|
@ -180,20 +198,26 @@ static void match_initial_magic_string(gpr_slice_buffer *buffer) {
|
|||
}
|
||||
|
||||
static void test_initial_string(test_tcp_server *server, int secure) {
|
||||
gpr_event ev;
|
||||
gpr_event_init(&ev);
|
||||
grpc_test_set_initial_connect_string_function(set_magic_initial_string);
|
||||
poll_server_until_read_done(server, &ev);
|
||||
start_rpc(secure, server_port);
|
||||
poll_server_until_read_done(server);
|
||||
gpr_event_wait(&ev, gpr_inf_future(GPR_CLOCK_REALTIME));
|
||||
match_initial_magic_string(&state.incoming_buffer);
|
||||
cleanup_rpc();
|
||||
}
|
||||
|
||||
static void test_initial_string_with_redirect(test_tcp_server *server,
|
||||
int secure) {
|
||||
gpr_event ev;
|
||||
gpr_event_init(&ev);
|
||||
int another_port = grpc_pick_unused_port_or_die();
|
||||
grpc_test_set_initial_connect_string_function(
|
||||
reset_addr_and_set_magic_string);
|
||||
poll_server_until_read_done(server, &ev);
|
||||
start_rpc(secure, another_port);
|
||||
poll_server_until_read_done(server);
|
||||
gpr_event_wait(&ev, gpr_inf_future(GPR_CLOCK_REALTIME));
|
||||
match_initial_magic_string(&state.incoming_buffer);
|
||||
cleanup_rpc();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,20 +32,22 @@
|
|||
*/
|
||||
|
||||
#include "src/core/lib/iomgr/udp_server.h"
|
||||
#include <grpc/grpc.h>
|
||||
#include <grpc/support/alloc.h>
|
||||
#include <grpc/support/log.h>
|
||||
#include <grpc/support/sync.h>
|
||||
#include <grpc/support/time.h>
|
||||
#include "src/core/lib/iomgr/ev_posix.h"
|
||||
#include "src/core/lib/iomgr/iomgr.h"
|
||||
#include "test/core/util/test_config.h"
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <string.h>
|
||||
#include <sys/socket.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <grpc/grpc.h>
|
||||
#include <grpc/support/alloc.h>
|
||||
#include <grpc/support/log.h>
|
||||
#include <grpc/support/sync.h>
|
||||
#include <grpc/support/time.h>
|
||||
|
||||
#include "src/core/lib/iomgr/ev_posix.h"
|
||||
#include "src/core/lib/iomgr/iomgr.h"
|
||||
#include "test/core/util/test_config.h"
|
||||
|
||||
#ifdef GRPC_NEED_UDP
|
||||
|
||||
#define LOG_TEST(x) gpr_log(GPR_INFO, "%s", #x)
|
||||
|
|
|
|||
|
|
@ -73,8 +73,10 @@ static void test_add_closure(void) {
|
|||
|
||||
gpr_mu_lock(g_mu);
|
||||
GPR_ASSERT(!done);
|
||||
grpc_pollset_work(&exec_ctx, g_pollset, &worker, gpr_now(deadline.clock_type),
|
||||
deadline);
|
||||
while (!done) {
|
||||
grpc_pollset_work(&exec_ctx, g_pollset, &worker,
|
||||
gpr_now(deadline.clock_type), deadline);
|
||||
}
|
||||
gpr_mu_unlock(g_mu);
|
||||
grpc_exec_ctx_finish(&exec_ctx);
|
||||
GPR_ASSERT(done);
|
||||
|
|
@ -97,9 +99,10 @@ static void test_flush(void) {
|
|||
grpc_workqueue_add_to_pollset(&exec_ctx, wq, g_pollset);
|
||||
|
||||
gpr_mu_lock(g_mu);
|
||||
GPR_ASSERT(!done);
|
||||
grpc_pollset_work(&exec_ctx, g_pollset, &worker, gpr_now(deadline.clock_type),
|
||||
deadline);
|
||||
while (!done) {
|
||||
grpc_pollset_work(&exec_ctx, g_pollset, &worker,
|
||||
gpr_now(deadline.clock_type), deadline);
|
||||
}
|
||||
gpr_mu_unlock(g_mu);
|
||||
grpc_exec_ctx_finish(&exec_ctx);
|
||||
GPR_ASSERT(done);
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ def mako_plugin(dictionary):
|
|||
'name': new_target['name'],
|
||||
'args': [fn],
|
||||
'exclude_configs': [],
|
||||
'uses_polling': False,
|
||||
'platforms': ['linux'],
|
||||
'ci_platforms': ['linux'],
|
||||
'flaky': False,
|
||||
|
|
|
|||
|
|
@ -808,6 +808,7 @@ src/core/lib/iomgr/closure.h \
|
|||
src/core/lib/iomgr/endpoint.h \
|
||||
src/core/lib/iomgr/endpoint_pair.h \
|
||||
src/core/lib/iomgr/ev_poll_and_epoll_posix.h \
|
||||
src/core/lib/iomgr/ev_poll_posix.h \
|
||||
src/core/lib/iomgr/ev_posix.h \
|
||||
src/core/lib/iomgr/exec_ctx.h \
|
||||
src/core/lib/iomgr/executor.h \
|
||||
|
|
@ -946,6 +947,7 @@ src/core/lib/iomgr/endpoint.c \
|
|||
src/core/lib/iomgr/endpoint_pair_posix.c \
|
||||
src/core/lib/iomgr/endpoint_pair_windows.c \
|
||||
src/core/lib/iomgr/ev_poll_and_epoll_posix.c \
|
||||
src/core/lib/iomgr/ev_poll_posix.c \
|
||||
src/core/lib/iomgr/ev_posix.c \
|
||||
src/core/lib/iomgr/exec_ctx.c \
|
||||
src/core/lib/iomgr/executor.c \
|
||||
|
|
|
|||
|
|
@ -344,6 +344,7 @@ class Jobset(object):
|
|||
self._add_env = add_env
|
||||
self.resultset = {}
|
||||
self._remaining = None
|
||||
self._start_time = time.time()
|
||||
|
||||
def set_remaining(self, remaining):
|
||||
self._remaining = remaining
|
||||
|
|
@ -413,6 +414,11 @@ class Jobset(object):
|
|||
if dead: return
|
||||
if (not self._travis):
|
||||
rstr = '' if self._remaining is None else '%d queued, ' % self._remaining
|
||||
if self._remaining is not None and self._completed > 0:
|
||||
now = time.time()
|
||||
sofar = now - self._start_time
|
||||
remaining = sofar / self._completed * (self._remaining + len(self._running))
|
||||
rstr = 'ETA %.1f sec; %s' % (remaining, rstr)
|
||||
message('WAITING', '%s%d jobs running, %d complete, %d failed' % (
|
||||
rstr, len(self._running), self._completed, self._failures))
|
||||
if platform_string() == 'windows':
|
||||
|
|
@ -457,7 +463,7 @@ def tag_remaining(xs):
|
|||
staging = []
|
||||
for x in xs:
|
||||
staging.append(x)
|
||||
if len(staging) > 1000:
|
||||
if len(staging) > 5000:
|
||||
yield (staging.pop(0), None)
|
||||
n = len(staging)
|
||||
for i, x in enumerate(staging):
|
||||
|
|
|
|||
|
|
@ -153,52 +153,64 @@ class CLanguage(object):
|
|||
def test_specs(self):
|
||||
out = []
|
||||
binaries = get_c_tests(self.args.travis, self.test_lang)
|
||||
POLLING_STRATEGIES = {
|
||||
'windows': ['all'],
|
||||
'mac': ['all'],
|
||||
'posix': ['all'],
|
||||
'linux': ['poll', 'legacy']
|
||||
}
|
||||
for target in binaries:
|
||||
if self.config.build_config in target['exclude_configs']:
|
||||
continue
|
||||
if self.platform == 'windows':
|
||||
binary = 'vsprojects/%s%s/%s.exe' % (
|
||||
'x64/' if self.args.arch == 'x64' else '',
|
||||
_MSBUILD_CONFIG[self.config.build_config],
|
||||
target['name'])
|
||||
else:
|
||||
binary = 'bins/%s/%s' % (self.config.build_config, target['name'])
|
||||
if os.path.isfile(binary):
|
||||
if 'gtest' in target and target['gtest']:
|
||||
# here we parse the output of --gtest_list_tests to build up a
|
||||
# complete list of the tests contained in a binary
|
||||
# for each test, we then add a job to run, filtering for just that
|
||||
# test
|
||||
with open(os.devnull, 'w') as fnull:
|
||||
tests = subprocess.check_output([binary, '--gtest_list_tests'],
|
||||
stderr=fnull)
|
||||
base = None
|
||||
for line in tests.split('\n'):
|
||||
i = line.find('#')
|
||||
if i >= 0: line = line[:i]
|
||||
if not line: continue
|
||||
if line[0] != ' ':
|
||||
base = line.strip()
|
||||
else:
|
||||
assert base is not None
|
||||
assert line[1] == ' '
|
||||
test = base + line.strip()
|
||||
cmdline = [binary] + ['--gtest_filter=%s' % test]
|
||||
out.append(self.config.job_spec(cmdline, [binary],
|
||||
shortname='%s:%s' % (binary, test),
|
||||
cpu_cost=target['cpu_cost'],
|
||||
environ={'GRPC_DEFAULT_SSL_ROOTS_FILE_PATH':
|
||||
_ROOT + '/src/core/lib/tsi/test_creds/ca.pem'}))
|
||||
polling_strategies = (POLLING_STRATEGIES[self.platform]
|
||||
if target.get('uses_polling', True)
|
||||
else ['all'])
|
||||
for polling_strategy in polling_strategies:
|
||||
env={'GRPC_DEFAULT_SSL_ROOTS_FILE_PATH':
|
||||
_ROOT + '/src/core/lib/tsi/test_creds/ca.pem',
|
||||
'GRPC_POLL_STRATEGY': polling_strategy}
|
||||
shortname_ext = '' if polling_strategy=='all' else ' polling=%s' % polling_strategy
|
||||
if self.config.build_config in target['exclude_configs']:
|
||||
continue
|
||||
if self.platform == 'windows':
|
||||
binary = 'vsprojects/%s%s/%s.exe' % (
|
||||
'x64/' if self.args.arch == 'x64' else '',
|
||||
_MSBUILD_CONFIG[self.config.build_config],
|
||||
target['name'])
|
||||
else:
|
||||
cmdline = [binary] + target['args']
|
||||
out.append(self.config.job_spec(cmdline, [binary],
|
||||
shortname=target.get('shortname', ' '.join(cmdline)),
|
||||
cpu_cost=target['cpu_cost'],
|
||||
flaky=target.get('flaky', False),
|
||||
environ={'GRPC_DEFAULT_SSL_ROOTS_FILE_PATH':
|
||||
_ROOT + '/src/core/lib/tsi/test_creds/ca.pem'}))
|
||||
elif self.args.regex == '.*' or self.platform == 'windows':
|
||||
print '\nWARNING: binary not found, skipping', binary
|
||||
binary = 'bins/%s/%s' % (self.config.build_config, target['name'])
|
||||
if os.path.isfile(binary):
|
||||
if 'gtest' in target and target['gtest']:
|
||||
# here we parse the output of --gtest_list_tests to build up a
|
||||
# complete list of the tests contained in a binary
|
||||
# for each test, we then add a job to run, filtering for just that
|
||||
# test
|
||||
with open(os.devnull, 'w') as fnull:
|
||||
tests = subprocess.check_output([binary, '--gtest_list_tests'],
|
||||
stderr=fnull)
|
||||
base = None
|
||||
for line in tests.split('\n'):
|
||||
i = line.find('#')
|
||||
if i >= 0: line = line[:i]
|
||||
if not line: continue
|
||||
if line[0] != ' ':
|
||||
base = line.strip()
|
||||
else:
|
||||
assert base is not None
|
||||
assert line[1] == ' '
|
||||
test = base + line.strip()
|
||||
cmdline = [binary] + ['--gtest_filter=%s' % test]
|
||||
out.append(self.config.job_spec(cmdline, [binary],
|
||||
shortname='%s:%s %s' % (binary, test, shortname_ext),
|
||||
cpu_cost=target['cpu_cost'],
|
||||
environ=env))
|
||||
else:
|
||||
cmdline = [binary] + target['args']
|
||||
out.append(self.config.job_spec(cmdline, [binary],
|
||||
shortname=' '.join(cmdline) + shortname_ext,
|
||||
cpu_cost=target['cpu_cost'],
|
||||
flaky=target.get('flaky', False),
|
||||
environ=env))
|
||||
elif self.args.regex == '.*' or self.platform == 'windows':
|
||||
print '\nWARNING: binary not found, skipping', binary
|
||||
return sorted(out)
|
||||
|
||||
def make_targets(self):
|
||||
|
|
|
|||
|
|
@ -5646,6 +5646,7 @@
|
|||
"src/core/lib/iomgr/endpoint.h",
|
||||
"src/core/lib/iomgr/endpoint_pair.h",
|
||||
"src/core/lib/iomgr/ev_poll_and_epoll_posix.h",
|
||||
"src/core/lib/iomgr/ev_poll_posix.h",
|
||||
"src/core/lib/iomgr/ev_posix.h",
|
||||
"src/core/lib/iomgr/exec_ctx.h",
|
||||
"src/core/lib/iomgr/executor.h",
|
||||
|
|
@ -5746,6 +5747,8 @@
|
|||
"src/core/lib/iomgr/endpoint_pair_windows.c",
|
||||
"src/core/lib/iomgr/ev_poll_and_epoll_posix.c",
|
||||
"src/core/lib/iomgr/ev_poll_and_epoll_posix.h",
|
||||
"src/core/lib/iomgr/ev_poll_posix.c",
|
||||
"src/core/lib/iomgr/ev_poll_posix.h",
|
||||
"src/core/lib/iomgr/ev_posix.c",
|
||||
"src/core/lib/iomgr/ev_posix.h",
|
||||
"src/core/lib/iomgr/exec_ctx.c",
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -317,6 +317,7 @@
|
|||
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\endpoint.h" />
|
||||
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\endpoint_pair.h" />
|
||||
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\ev_poll_and_epoll_posix.h" />
|
||||
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\ev_poll_posix.h" />
|
||||
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\ev_posix.h" />
|
||||
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\exec_ctx.h" />
|
||||
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\executor.h" />
|
||||
|
|
@ -476,6 +477,8 @@
|
|||
</ClCompile>
|
||||
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\ev_poll_and_epoll_posix.c">
|
||||
</ClCompile>
|
||||
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\ev_poll_posix.c">
|
||||
</ClCompile>
|
||||
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\ev_posix.c">
|
||||
</ClCompile>
|
||||
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\exec_ctx.c">
|
||||
|
|
|
|||
|
|
@ -58,6 +58,9 @@
|
|||
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\ev_poll_and_epoll_posix.c">
|
||||
<Filter>src\core\lib\iomgr</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\ev_poll_posix.c">
|
||||
<Filter>src\core\lib\iomgr</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\ev_posix.c">
|
||||
<Filter>src\core\lib\iomgr</Filter>
|
||||
</ClCompile>
|
||||
|
|
@ -653,6 +656,9 @@
|
|||
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\ev_poll_and_epoll_posix.h">
|
||||
<Filter>src\core\lib\iomgr</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\ev_poll_posix.h">
|
||||
<Filter>src\core\lib\iomgr</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\ev_posix.h">
|
||||
<Filter>src\core\lib\iomgr</Filter>
|
||||
</ClInclude>
|
||||
|
|
|
|||
|
|
@ -305,6 +305,7 @@
|
|||
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\endpoint.h" />
|
||||
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\endpoint_pair.h" />
|
||||
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\ev_poll_and_epoll_posix.h" />
|
||||
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\ev_poll_posix.h" />
|
||||
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\ev_posix.h" />
|
||||
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\exec_ctx.h" />
|
||||
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\executor.h" />
|
||||
|
|
@ -451,6 +452,8 @@
|
|||
</ClCompile>
|
||||
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\ev_poll_and_epoll_posix.c">
|
||||
</ClCompile>
|
||||
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\ev_poll_posix.c">
|
||||
</ClCompile>
|
||||
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\ev_posix.c">
|
||||
</ClCompile>
|
||||
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\exec_ctx.c">
|
||||
|
|
|
|||
|
|
@ -61,6 +61,9 @@
|
|||
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\ev_poll_and_epoll_posix.c">
|
||||
<Filter>src\core\lib\iomgr</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\ev_poll_posix.c">
|
||||
<Filter>src\core\lib\iomgr</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\ev_posix.c">
|
||||
<Filter>src\core\lib\iomgr</Filter>
|
||||
</ClCompile>
|
||||
|
|
@ -575,6 +578,9 @@
|
|||
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\ev_poll_and_epoll_posix.h">
|
||||
<Filter>src\core\lib\iomgr</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\ev_poll_posix.h">
|
||||
<Filter>src\core\lib\iomgr</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\ev_posix.h">
|
||||
<Filter>src\core\lib\iomgr</Filter>
|
||||
</ClInclude>
|
||||
|
|
|
|||
Loading…
Reference in New Issue