aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--BUILD8
-rw-r--r--Makefile4
-rw-r--r--build.json4
-rw-r--r--src/core/channel/client_channel.c7
-rw-r--r--src/core/channel/client_setup.c64
-rw-r--r--src/core/channel/client_setup.h2
-rw-r--r--src/core/httpcli/httpcli.c7
-rw-r--r--src/core/httpcli/httpcli.h4
-rw-r--r--src/core/iomgr/fd_posix.c1
-rw-r--r--src/core/iomgr/pollset.h1
-rw-r--r--src/core/iomgr/pollset_posix.c57
-rw-r--r--src/core/iomgr/pollset_posix.h6
-rw-r--r--src/core/iomgr/pollset_set.h57
-rw-r--r--src/core/iomgr/pollset_set_posix.c111
-rw-r--r--src/core/iomgr/pollset_set_posix.h55
-rw-r--r--src/core/iomgr/pollset_set_windows.c49
-rw-r--r--src/core/iomgr/pollset_set_windows.h40
-rw-r--r--src/core/iomgr/tcp_client.h6
-rw-r--r--src/core/iomgr/tcp_client_posix.c18
-rw-r--r--src/core/iomgr/tcp_client_windows.c7
-rw-r--r--src/core/iomgr/tcp_server_posix.c77
-rw-r--r--src/core/security/credentials.c15
-rw-r--r--src/core/security/credentials.h1
-rw-r--r--src/core/security/google_default_credentials.c30
-rw-r--r--src/core/surface/call.c7
-rw-r--r--src/core/surface/channel_create.c7
-rw-r--r--src/core/surface/secure_channel_create.c7
-rw-r--r--src/core/transport/transport.c8
-rw-r--r--src/core/transport/transport.h7
-rw-r--r--test/core/end2end/dualstack_socket_test.c48
-rw-r--r--test/core/end2end/end2end_tests.h3
-rw-r--r--test/core/end2end/fixtures/chttp2_fake_security.c5
-rw-r--r--test/core/end2end/fixtures/chttp2_fullstack.c5
-rw-r--r--test/core/end2end/fixtures/chttp2_fullstack_uds_posix.c5
-rw-r--r--test/core/end2end/fixtures/chttp2_simple_ssl_fullstack.c5
-rw-r--r--test/core/end2end/fixtures/chttp2_simple_ssl_with_oauth2_fullstack.c5
-rw-r--r--test/core/end2end/fixtures/chttp2_socket_pair.c5
-rw-r--r--test/core/end2end/fixtures/chttp2_socket_pair_one_byte_at_a_time.c5
-rw-r--r--test/core/end2end/tests/bad_hostname.c19
-rw-r--r--test/core/end2end/tests/cancel_after_accept.c33
-rw-r--r--test/core/end2end/tests/cancel_after_accept_and_writes_closed.c33
-rw-r--r--test/core/end2end/tests/cancel_after_invoke.c19
-rw-r--r--test/core/end2end/tests/cancel_before_invoke.c19
-rw-r--r--test/core/end2end/tests/cancel_in_a_vacuum.c13
-rw-r--r--test/core/end2end/tests/census_simple_request.c33
-rw-r--r--test/core/end2end/tests/disappearing_server.c40
-rw-r--r--test/core/end2end/tests/early_server_shutdown_finishes_inflight_calls.c33
-rw-r--r--test/core/end2end/tests/early_server_shutdown_finishes_tags.c21
-rw-r--r--test/core/end2end/tests/empty_batch.c19
-rw-r--r--test/core/end2end/tests/graceful_server_shutdown.c39
-rw-r--r--test/core/end2end/tests/invoke_large_request.c33
-rw-r--r--test/core/end2end/tests/max_concurrent_streams.c114
-rw-r--r--test/core/end2end/tests/max_message_length.c36
-rw-r--r--test/core/end2end/tests/no_op.c9
-rw-r--r--test/core/end2end/tests/ping_pong_streaming.c49
-rw-r--r--test/core/end2end/tests/registered_call.c33
-rw-r--r--test/core/end2end/tests/request_response_with_binary_metadata_and_payload.c33
-rw-r--r--test/core/end2end/tests/request_response_with_metadata_and_payload.c33
-rw-r--r--test/core/end2end/tests/request_response_with_payload.c33
-rw-r--r--test/core/end2end/tests/request_response_with_payload_and_call_creds.c33
-rw-r--r--test/core/end2end/tests/request_with_large_metadata.c33
-rw-r--r--test/core/end2end/tests/request_with_payload.c33
-rw-r--r--test/core/end2end/tests/simple_delayed_request.c33
-rw-r--r--test/core/end2end/tests/simple_request.c33
-rw-r--r--test/core/end2end/tests/simple_request_with_high_initial_sequence_number.c33
-rw-r--r--test/core/httpcli/httpcli_test.c26
-rw-r--r--test/core/iomgr/endpoint_tests.c80
-rw-r--r--test/core/iomgr/endpoint_tests.h2
-rw-r--r--test/core/iomgr/fd_posix_test.c88
-rw-r--r--test/core/iomgr/tcp_client_posix_test.c88
-rw-r--r--test/core/iomgr/tcp_posix_test.c88
-rw-r--r--test/core/iomgr/tcp_server_posix_test.c50
-rw-r--r--test/core/security/secure_endpoint_test.c12
-rw-r--r--test/cpp/end2end/async_end2end_test.cc230
-rwxr-xr-xtools/run_tests/run_tests.py13
-rw-r--r--vsprojects/grpc/grpc.vcxproj6
-rw-r--r--vsprojects/grpc/grpc.vcxproj.filters12
-rw-r--r--vsprojects/grpc_unsecure/grpc_unsecure.vcxproj6
-rw-r--r--vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters12
79 files changed, 1345 insertions, 1013 deletions
diff --git a/BUILD b/BUILD
index f7136e4b84..cfaa6bd91d 100644
--- a/BUILD
+++ b/BUILD
@@ -168,6 +168,8 @@ cc_library(
"src/core/iomgr/pollset_kick_posix.h",
"src/core/iomgr/pollset_kick_windows.h",
"src/core/iomgr/pollset_posix.h",
+ "src/core/iomgr/pollset_set_posix.h",
+ "src/core/iomgr/pollset_set_windows.h",
"src/core/iomgr/pollset_windows.h",
"src/core/iomgr/resolve_address.h",
"src/core/iomgr/sockaddr.h",
@@ -275,6 +277,8 @@ cc_library(
"src/core/iomgr/pollset_multipoller_with_epoll.c",
"src/core/iomgr/pollset_multipoller_with_poll_posix.c",
"src/core/iomgr/pollset_posix.c",
+ "src/core/iomgr/pollset_set_posix.c",
+ "src/core/iomgr/pollset_set_windows.c",
"src/core/iomgr/pollset_windows.c",
"src/core/iomgr/resolve_address_posix.c",
"src/core/iomgr/resolve_address_windows.c",
@@ -396,6 +400,8 @@ cc_library(
"src/core/iomgr/pollset_kick_posix.h",
"src/core/iomgr/pollset_kick_windows.h",
"src/core/iomgr/pollset_posix.h",
+ "src/core/iomgr/pollset_set_posix.h",
+ "src/core/iomgr/pollset_set_windows.h",
"src/core/iomgr/pollset_windows.h",
"src/core/iomgr/resolve_address.h",
"src/core/iomgr/sockaddr.h",
@@ -483,6 +489,8 @@ cc_library(
"src/core/iomgr/pollset_multipoller_with_epoll.c",
"src/core/iomgr/pollset_multipoller_with_poll_posix.c",
"src/core/iomgr/pollset_posix.c",
+ "src/core/iomgr/pollset_set_posix.c",
+ "src/core/iomgr/pollset_set_windows.c",
"src/core/iomgr/pollset_windows.c",
"src/core/iomgr/resolve_address_posix.c",
"src/core/iomgr/resolve_address_windows.c",
diff --git a/Makefile b/Makefile
index 93b5f8b78f..cd5858c1c8 100644
--- a/Makefile
+++ b/Makefile
@@ -2459,6 +2459,8 @@ LIBGRPC_SRC = \
src/core/iomgr/pollset_multipoller_with_epoll.c \
src/core/iomgr/pollset_multipoller_with_poll_posix.c \
src/core/iomgr/pollset_posix.c \
+ src/core/iomgr/pollset_set_posix.c \
+ src/core/iomgr/pollset_set_windows.c \
src/core/iomgr/pollset_windows.c \
src/core/iomgr/resolve_address_posix.c \
src/core/iomgr/resolve_address_windows.c \
@@ -2708,6 +2710,8 @@ LIBGRPC_UNSECURE_SRC = \
src/core/iomgr/pollset_multipoller_with_epoll.c \
src/core/iomgr/pollset_multipoller_with_poll_posix.c \
src/core/iomgr/pollset_posix.c \
+ src/core/iomgr/pollset_set_posix.c \
+ src/core/iomgr/pollset_set_windows.c \
src/core/iomgr/pollset_windows.c \
src/core/iomgr/resolve_address_posix.c \
src/core/iomgr/resolve_address_windows.c \
diff --git a/build.json b/build.json
index 28a5b4b740..8d256e9a2f 100644
--- a/build.json
+++ b/build.json
@@ -120,6 +120,8 @@
"src/core/iomgr/pollset_kick_posix.h",
"src/core/iomgr/pollset_kick_windows.h",
"src/core/iomgr/pollset_posix.h",
+ "src/core/iomgr/pollset_set_posix.h",
+ "src/core/iomgr/pollset_set_windows.h",
"src/core/iomgr/pollset_windows.h",
"src/core/iomgr/resolve_address.h",
"src/core/iomgr/sockaddr.h",
@@ -208,6 +210,8 @@
"src/core/iomgr/pollset_multipoller_with_epoll.c",
"src/core/iomgr/pollset_multipoller_with_poll_posix.c",
"src/core/iomgr/pollset_posix.c",
+ "src/core/iomgr/pollset_set_posix.c",
+ "src/core/iomgr/pollset_set_windows.c",
"src/core/iomgr/pollset_windows.c",
"src/core/iomgr/resolve_address_posix.c",
"src/core/iomgr/resolve_address_windows.c",
diff --git a/src/core/channel/client_channel.c b/src/core/channel/client_channel.c
index 78f8d06d89..9f23ed3d71 100644
--- a/src/core/channel/client_channel.c
+++ b/src/core/channel/client_channel.c
@@ -39,6 +39,7 @@
#include "src/core/channel/child_channel.h"
#include "src/core/channel/connected_channel.h"
#include "src/core/iomgr/iomgr.h"
+#include "src/core/iomgr/pollset_set.h"
#include "src/core/support/string.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
@@ -131,7 +132,10 @@ static void remove_waiting_child(channel_data *chand, call_data *calld) {
size_t new_count;
size_t i;
for (i = 0, new_count = 0; i < chand->waiting_child_count; i++) {
- if (chand->waiting_children[i] == calld) continue;
+ if (chand->waiting_children[i] == calld) {
+ grpc_transport_setup_del_interested_party(chand->transport_setup, calld->s.waiting_op.bind_pollset);
+ continue;
+ }
chand->waiting_children[new_count++] = chand->waiting_children[i];
}
GPR_ASSERT(new_count == chand->waiting_child_count - 1 ||
@@ -227,6 +231,7 @@ static void cc_start_transport_op(grpc_call_element *elem,
if (initiate_transport_setup) {
grpc_transport_setup_initiate(chand->transport_setup);
}
+ grpc_transport_setup_add_interested_party(chand->transport_setup, op->bind_pollset);
}
}
break;
diff --git a/src/core/channel/client_setup.c b/src/core/channel/client_setup.c
index 6d892d6c92..e2bd7ef52e 100644
--- a/src/core/channel/client_setup.c
+++ b/src/core/channel/client_setup.c
@@ -61,6 +61,7 @@ struct grpc_client_setup {
struct grpc_client_setup_request {
/* pointer back to the setup object */
grpc_client_setup *setup;
+ grpc_pollset_set interested_parties;
gpr_timespec deadline;
};
@@ -68,6 +69,11 @@ gpr_timespec grpc_client_setup_request_deadline(grpc_client_setup_request *r) {
return r->deadline;
}
+grpc_pollset_set *grpc_client_setup_get_interested_parties(
+ grpc_client_setup_request *r) {
+ return &r->interested_parties;
+}
+
static void destroy_setup(grpc_client_setup *s) {
gpr_mu_destroy(&s->mu);
gpr_cv_destroy(&s->cv);
@@ -76,6 +82,11 @@ static void destroy_setup(grpc_client_setup *s) {
gpr_free(s);
}
+static void destroy_request(grpc_client_setup_request *r) {
+ grpc_pollset_set_destroy(&r->interested_parties);
+ gpr_free(r);
+}
+
/* initiate handshaking */
static void setup_initiate(grpc_transport_setup *sp) {
grpc_client_setup *s = (grpc_client_setup *)sp;
@@ -83,6 +94,7 @@ static void setup_initiate(grpc_transport_setup *sp) {
int in_alarm = 0;
r->setup = s;
+ grpc_pollset_set_init(&r->interested_parties);
/* TODO(klempner): Actually set a deadline */
r->deadline = gpr_inf_future;
@@ -104,8 +116,36 @@ static void setup_initiate(grpc_transport_setup *sp) {
if (!in_alarm) {
s->initiate(s->user_data, r);
} else {
- gpr_free(r);
+ destroy_request(r);
+ }
+}
+
+static void setup_add_interested_party(grpc_transport_setup *sp, grpc_pollset *pollset) {
+ grpc_client_setup *s = (grpc_client_setup *)sp;
+
+ gpr_mu_lock(&s->mu);
+ if (!s->active_request) {
+ gpr_mu_unlock(&s->mu);
+ return;
+ }
+
+ grpc_pollset_set_add_pollset(&s->active_request->interested_parties, pollset);
+
+ gpr_mu_unlock(&s->mu);
+}
+
+static void setup_del_interested_party(grpc_transport_setup *sp, grpc_pollset *pollset) {
+ grpc_client_setup *s = (grpc_client_setup *)sp;
+
+ gpr_mu_lock(&s->mu);
+ if (!s->active_request) {
+ gpr_mu_unlock(&s->mu);
+ return;
}
+
+ grpc_pollset_set_del_pollset(&s->active_request->interested_parties, pollset);
+
+ gpr_mu_unlock(&s->mu);
}
/* cancel handshaking: cancel all requests, and shutdown (the caller promises
@@ -157,6 +197,8 @@ void grpc_client_setup_cb_end(grpc_client_setup_request *r) {
/* vtable for transport setup */
static const grpc_transport_setup_vtable setup_vtable = {setup_initiate,
+ setup_add_interested_party,
+ setup_del_interested_party,
setup_cancel};
void grpc_client_setup_create_and_attach(
@@ -196,26 +238,24 @@ int grpc_client_setup_request_should_continue(grpc_client_setup_request *r) {
}
static void backoff_alarm_done(void *arg /* grpc_client_setup */, int success) {
- grpc_client_setup *s = arg;
- grpc_client_setup_request *r = gpr_malloc(sizeof(grpc_client_setup_request));
- r->setup = s;
- /* TODO(klempner): Set this to something useful */
- r->deadline = gpr_inf_future;
+ grpc_client_setup_request *r = arg;
+ grpc_client_setup *s = r->setup;
/* Handle status cancelled? */
gpr_mu_lock(&s->mu);
- s->active_request = r;
s->in_alarm = 0;
- if (!success) {
+ if (s->active_request != NULL || !success) {
if (0 == --s->refs) {
gpr_mu_unlock(&s->mu);
destroy_setup(s);
- gpr_free(r);
+ destroy_request(r);
return;
} else {
gpr_mu_unlock(&s->mu);
+ destroy_request(r);
return;
}
}
+ s->active_request = r;
gpr_mu_unlock(&s->mu);
s->initiate(s->user_data, r);
}
@@ -234,12 +274,10 @@ void grpc_client_setup_request_finish(grpc_client_setup_request *r,
if (!retry && 0 == --s->refs) {
gpr_mu_unlock(&s->mu);
destroy_setup(s);
- gpr_free(r);
+ destroy_request(r);
return;
}
- gpr_free(r);
-
if (retry) {
/* TODO(klempner): Replace these values with further consideration. 2x is
probably too aggressive of a backoff. */
@@ -248,7 +286,7 @@ void grpc_client_setup_request_finish(grpc_client_setup_request *r,
gpr_timespec deadline = gpr_time_add(s->current_backoff_interval, now);
GPR_ASSERT(!s->in_alarm);
s->in_alarm = 1;
- grpc_alarm_init(&s->backoff_alarm, deadline, backoff_alarm_done, s, now);
+ grpc_alarm_init(&s->backoff_alarm, deadline, backoff_alarm_done, r, now);
s->current_backoff_interval =
gpr_time_add(s->current_backoff_interval, s->current_backoff_interval);
if (gpr_time_cmp(s->current_backoff_interval, max_backoff) > 0) {
diff --git a/src/core/channel/client_setup.h b/src/core/channel/client_setup.h
index 70137e1365..2486da5dbf 100644
--- a/src/core/channel/client_setup.h
+++ b/src/core/channel/client_setup.h
@@ -67,6 +67,8 @@ void grpc_client_setup_cb_end(grpc_client_setup_request *r);
/* Get the deadline for a request passed in to initiate. Implementations should
make a best effort to honor this deadline. */
gpr_timespec grpc_client_setup_request_deadline(grpc_client_setup_request *r);
+grpc_pollset_set *grpc_client_setup_get_interested_parties(
+ grpc_client_setup_request *r);
grpc_mdctx *grpc_client_setup_get_mdctx(grpc_client_setup_request *r);
diff --git a/src/core/httpcli/httpcli.c b/src/core/httpcli/httpcli.c
index fe7ea6a86b..54cc992545 100644
--- a/src/core/httpcli/httpcli.c
+++ b/src/core/httpcli/httpcli.c
@@ -59,6 +59,7 @@ typedef struct {
int use_ssl;
grpc_httpcli_response_cb on_response;
void *user_data;
+ grpc_pollset_set *interested_parties;
} internal_request;
static grpc_httpcli_get_override g_get_override = NULL;
@@ -206,7 +207,7 @@ static void next_address(internal_request *req) {
return;
}
addr = &req->addresses->addrs[req->next_address++];
- grpc_tcp_client_connect(on_connected, req, (struct sockaddr *)&addr->addr,
+ grpc_tcp_client_connect(on_connected, req, req->interested_parties, (struct sockaddr *)&addr->addr,
addr->len, req->deadline);
}
@@ -224,6 +225,7 @@ static void on_resolved(void *arg, grpc_resolved_addresses *addresses) {
void grpc_httpcli_get(const grpc_httpcli_request *request,
gpr_timespec deadline,
+ grpc_pollset_set *interested_parties,
grpc_httpcli_response_cb on_response, void *user_data) {
internal_request *req;
if (g_get_override &&
@@ -238,6 +240,7 @@ void grpc_httpcli_get(const grpc_httpcli_request *request,
req->user_data = user_data;
req->deadline = deadline;
req->use_ssl = request->use_ssl;
+ req->interested_parties = interested_parties;
if (req->use_ssl) {
req->host = gpr_strdup(request->host);
}
@@ -249,6 +252,7 @@ void grpc_httpcli_get(const grpc_httpcli_request *request,
void grpc_httpcli_post(const grpc_httpcli_request *request,
const char *body_bytes, size_t body_size,
gpr_timespec deadline,
+ grpc_pollset_set *interested_parties,
grpc_httpcli_response_cb on_response, void *user_data) {
internal_request *req;
if (g_post_override && g_post_override(request, body_bytes, body_size,
@@ -264,6 +268,7 @@ void grpc_httpcli_post(const grpc_httpcli_request *request,
req->user_data = user_data;
req->deadline = deadline;
req->use_ssl = request->use_ssl;
+ req->interested_parties = interested_parties;
if (req->use_ssl) {
req->host = gpr_strdup(request->host);
}
diff --git a/src/core/httpcli/httpcli.h b/src/core/httpcli/httpcli.h
index 255c5ed90f..fec435b32d 100644
--- a/src/core/httpcli/httpcli.h
+++ b/src/core/httpcli/httpcli.h
@@ -38,6 +38,8 @@
#include <grpc/support/time.h>
+#include "src/core/iomgr/pollset_set.h"
+
/* User agent this library reports */
#define GRPC_HTTPCLI_USER_AGENT "grpc-httpcli/0.0"
/* Maximum length of a header string of the form 'Key: Value\r\n' */
@@ -90,6 +92,7 @@ typedef void (*grpc_httpcli_response_cb)(void *user_data,
supplied pointer to pass to said call) */
void grpc_httpcli_get(const grpc_httpcli_request *request,
gpr_timespec deadline,
+ grpc_pollset_set *interested_parties,
grpc_httpcli_response_cb on_response, void *user_data);
/* Asynchronously perform a HTTP POST.
@@ -98,6 +101,7 @@ void grpc_httpcli_get(const grpc_httpcli_request *request,
void grpc_httpcli_post(const grpc_httpcli_request *request,
const char *body_bytes, size_t body_size,
gpr_timespec deadline,
+ grpc_pollset_set *interested_parties,
grpc_httpcli_response_cb on_response, void *user_data);
/* override functions return 1 if they handled the request, 0 otherwise */
diff --git a/src/core/iomgr/fd_posix.c b/src/core/iomgr/fd_posix.c
index 9c8133d2d4..cafe52b4d4 100644
--- a/src/core/iomgr/fd_posix.c
+++ b/src/core/iomgr/fd_posix.c
@@ -139,7 +139,6 @@ static void do_nothing(void *ignored, int success) {}
grpc_fd *grpc_fd_create(int fd) {
grpc_fd *r = alloc_fd(fd);
grpc_iomgr_ref();
- grpc_pollset_add_fd(grpc_backup_pollset(), r);
return r;
}
diff --git a/src/core/iomgr/pollset.h b/src/core/iomgr/pollset.h
index 067af87c93..334e0ebde1 100644
--- a/src/core/iomgr/pollset.h
+++ b/src/core/iomgr/pollset.h
@@ -52,7 +52,6 @@
#include "src/core/iomgr/pollset_windows.h"
#endif
-
void grpc_pollset_init(grpc_pollset *pollset);
void grpc_pollset_shutdown(grpc_pollset *pollset,
void (*shutdown_done)(void *arg),
diff --git a/src/core/iomgr/pollset_posix.c b/src/core/iomgr/pollset_posix.c
index 4d1bcad9e2..8ffc5e877e 100644
--- a/src/core/iomgr/pollset_posix.c
+++ b/src/core/iomgr/pollset_posix.c
@@ -54,31 +54,8 @@
#include <grpc/support/tls.h>
#include <grpc/support/useful.h>
-static grpc_pollset g_backup_pollset;
-static int g_shutdown_backup_poller;
-static gpr_event g_backup_poller_done;
-static gpr_event g_backup_pollset_shutdown_done;
-
GPR_TLS_DECL(g_current_thread_poller);
-static void backup_poller(void *p) {
- gpr_timespec delta = gpr_time_from_millis(100);
- gpr_timespec last_poll = gpr_now();
-
- gpr_mu_lock(&g_backup_pollset.mu);
- while (g_shutdown_backup_poller == 0) {
- gpr_timespec next_poll = gpr_time_add(last_poll, delta);
- grpc_pollset_work(&g_backup_pollset, gpr_time_add(gpr_now(), gpr_time_from_seconds(1)));
- gpr_mu_unlock(&g_backup_pollset.mu);
- gpr_sleep_until(next_poll);
- gpr_mu_lock(&g_backup_pollset.mu);
- last_poll = next_poll;
- }
- gpr_mu_unlock(&g_backup_pollset.mu);
-
- gpr_event_set(&g_backup_poller_done, (void *)1);
-}
-
void grpc_pollset_kick(grpc_pollset *p) {
if (gpr_tls_get(&g_current_thread_poller) != (gpr_intptr)p && p->counter) {
p->vtable->kick(p);
@@ -99,44 +76,14 @@ static void kick_using_pollset_kick(grpc_pollset *p) {
/* global state management */
-grpc_pollset *grpc_backup_pollset(void) { return &g_backup_pollset; }
-
void grpc_pollset_global_init(void) {
- gpr_thd_id id;
-
gpr_tls_init(&g_current_thread_poller);
/* Initialize kick fd state */
grpc_pollset_kick_global_init();
-
- /* initialize the backup pollset */
- grpc_pollset_init(&g_backup_pollset);
-
- /* start the backup poller thread */
- g_shutdown_backup_poller = 0;
- gpr_event_init(&g_backup_poller_done);
- gpr_event_init(&g_backup_pollset_shutdown_done);
- gpr_thd_new(&id, backup_poller, NULL, NULL);
-}
-
-static void on_backup_pollset_shutdown_done(void *arg) {
- gpr_event_set(&g_backup_pollset_shutdown_done, (void *)1);
}
void grpc_pollset_global_shutdown(void) {
- /* terminate the backup poller thread */
- gpr_mu_lock(&g_backup_pollset.mu);
- g_shutdown_backup_poller = 1;
- gpr_mu_unlock(&g_backup_pollset.mu);
- gpr_event_wait(&g_backup_poller_done, gpr_inf_future);
-
- grpc_pollset_shutdown(&g_backup_pollset, on_backup_pollset_shutdown_done,
- NULL);
- gpr_event_wait(&g_backup_pollset_shutdown_done, gpr_inf_future);
-
- /* destroy the backup pollset */
- grpc_pollset_destroy(&g_backup_pollset);
-
/* destroy the kick pipes */
grpc_pollset_kick_global_destroy();
@@ -227,6 +174,8 @@ static void empty_pollset_del_fd(grpc_pollset *pollset, grpc_fd *fd) {}
static int empty_pollset_maybe_work(grpc_pollset *pollset,
gpr_timespec deadline, gpr_timespec now,
int allow_synchronous_callback) {
+ gpr_mu_unlock(&pollset->mu);
+ gpr_mu_lock(&pollset->mu);
return 0;
}
@@ -380,6 +329,8 @@ static int unary_poll_pollset_maybe_work(grpc_pollset *pollset,
}
if (pollset->in_flight_cbs) {
/* Give do_promote priority so we don't starve it out */
+ gpr_mu_unlock(&pollset->mu);
+ gpr_mu_lock(&pollset->mu);
return 0;
}
fd = pollset->data.ptr;
diff --git a/src/core/iomgr/pollset_posix.h b/src/core/iomgr/pollset_posix.h
index da843f7381..1a92e151ac 100644
--- a/src/core/iomgr/pollset_posix.h
+++ b/src/core/iomgr/pollset_posix.h
@@ -94,12 +94,6 @@ int grpc_kick_read_fd(grpc_pollset *p);
/* Call after polling has been kicked to leave the kicked state */
void grpc_kick_drain(grpc_pollset *p);
-/* All fds get added to a backup pollset to ensure that progress is made
- regardless of applications listening to events. Relying on this is slow
- however (the backup pollset only listens every 100ms or so) - so it's not
- to be relied on. */
-grpc_pollset *grpc_backup_pollset(void);
-
/* turn a pollset into a multipoller: platform specific */
void grpc_platform_become_multipoller(grpc_pollset *pollset,
struct grpc_fd **fds, size_t fd_count);
diff --git a/src/core/iomgr/pollset_set.h b/src/core/iomgr/pollset_set.h
new file mode 100644
index 0000000000..70a80608c4
--- /dev/null
+++ b/src/core/iomgr/pollset_set.h
@@ -0,0 +1,57 @@
+/*
+ *
+ * Copyright 2015, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef GRPC_INTERNAL_CORE_IOMGR_POLLSET_SET_H
+#define GRPC_INTERNAL_CORE_IOMGR_POLLSET_SET_H
+
+#include "src/core/iomgr/pollset.h"
+
+/* A grpc_pollset_set is a set of pollsets that are interested in an
+ action. Adding a pollset to a pollset_set automatically adds any
+ fd's (etc) that have been registered with the set_set with that pollset.
+ Registering fd's automatically iterates all current pollsets. */
+
+#ifdef GPR_POSIX_SOCKET
+#include "src/core/iomgr/pollset_set_posix.h"
+#endif
+
+#ifdef GPR_WIN32
+#include "src/core/iomgr/pollset_set_windows.h"
+#endif
+
+void grpc_pollset_set_init(grpc_pollset_set *pollset_set);
+void grpc_pollset_set_destroy(grpc_pollset_set *pollset_set);
+void grpc_pollset_set_add_pollset(grpc_pollset_set *pollset_set, grpc_pollset *pollset);
+void grpc_pollset_set_del_pollset(grpc_pollset_set *pollset_set, grpc_pollset *pollset);
+
+#endif /* GRPC_INTERNAL_CORE_IOMGR_POLLSET_H */
diff --git a/src/core/iomgr/pollset_set_posix.c b/src/core/iomgr/pollset_set_posix.c
new file mode 100644
index 0000000000..f54237f670
--- /dev/null
+++ b/src/core/iomgr/pollset_set_posix.c
@@ -0,0 +1,111 @@
+/*
+ *
+ * Copyright 2015, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include <grpc/support/port_platform.h>
+
+#ifdef GPR_POSIX_SOCKET
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <grpc/support/alloc.h>
+#include <grpc/support/useful.h>
+
+#include "src/core/iomgr/pollset_set.h"
+
+void grpc_pollset_set_init(grpc_pollset_set *pollset_set) {
+ memset(pollset_set, 0, sizeof(*pollset_set));
+ gpr_mu_init(&pollset_set->mu);
+}
+
+void grpc_pollset_set_destroy(grpc_pollset_set *pollset_set) {
+ gpr_mu_destroy(&pollset_set->mu);
+ gpr_free(pollset_set->pollsets);
+ gpr_free(pollset_set->fds);
+}
+
+void grpc_pollset_set_add_pollset(grpc_pollset_set *pollset_set, grpc_pollset *pollset) {
+ size_t i;
+ gpr_mu_lock(&pollset_set->mu);
+ if (pollset_set->pollset_count == pollset_set->pollset_capacity) {
+ pollset_set->pollset_capacity = GPR_MAX(8, 2 * pollset_set->pollset_capacity);
+ pollset_set->pollsets = gpr_realloc(pollset_set->pollsets, pollset_set->pollset_capacity * sizeof(*pollset_set->pollsets));
+ }
+ pollset_set->pollsets[pollset_set->pollset_count++] = pollset;
+ for (i = 0; i < pollset_set->fd_count; i++) {
+ grpc_pollset_add_fd(pollset, pollset_set->fds[i]);
+ }
+ gpr_mu_unlock(&pollset_set->mu);
+}
+
+void grpc_pollset_set_del_pollset(grpc_pollset_set *pollset_set, grpc_pollset *pollset) {
+ size_t i;
+ gpr_mu_lock(&pollset_set->mu);
+ for (i = 0; i < pollset_set->pollset_count; i++) {
+ if (pollset_set->pollsets[i] == pollset) {
+ pollset_set->pollset_count--;
+ GPR_SWAP(grpc_pollset *, pollset_set->pollsets[i], pollset_set->pollsets[pollset_set->pollset_count]);
+ break;
+ }
+ }
+ gpr_mu_unlock(&pollset_set->mu);
+}
+
+void grpc_pollset_set_add_fd(grpc_pollset_set *pollset_set, grpc_fd *fd) {
+ size_t i;
+ gpr_mu_lock(&pollset_set->mu);
+ if (pollset_set->fd_count == pollset_set->fd_capacity) {
+ pollset_set->fd_capacity = GPR_MAX(8, 2 * pollset_set->fd_capacity);
+ pollset_set->fds = gpr_realloc(pollset_set->fds, pollset_set->fd_capacity * sizeof(*pollset_set->fds));
+ }
+ pollset_set->fds[pollset_set->fd_count++] = fd;
+ for (i = 0; i < pollset_set->pollset_count; i++) {
+ grpc_pollset_add_fd(pollset_set->pollsets[i], fd);
+ }
+ gpr_mu_unlock(&pollset_set->mu);
+}
+
+void grpc_pollset_set_del_fd(grpc_pollset_set *pollset_set, grpc_fd *fd) {
+ size_t i;
+ gpr_mu_lock(&pollset_set->mu);
+ for (i = 0; i < pollset_set->fd_count; i++) {
+ if (pollset_set->fds[i] == fd) {
+ pollset_set->fd_count--;
+ GPR_SWAP(grpc_fd *, pollset_set->fds[i], pollset_set->fds[pollset_set->pollset_count]);
+ break;
+ }
+ }
+ gpr_mu_unlock(&pollset_set->mu);
+}
+
+#endif /* GPR_POSIX_SOCKET */
diff --git a/src/core/iomgr/pollset_set_posix.h b/src/core/iomgr/pollset_set_posix.h
new file mode 100644
index 0000000000..73c6e0efb0
--- /dev/null
+++ b/src/core/iomgr/pollset_set_posix.h
@@ -0,0 +1,55 @@
+/*
+ *
+ * Copyright 2015, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef GRPC_INTERNAL_CORE_IOMGR_POLLSET_SET_POSIX_H
+#define GRPC_INTERNAL_CORE_IOMGR_POLLSET_SET_POSIX_H
+
+#include "src/core/iomgr/fd_posix.h"
+#include "src/core/iomgr/pollset_posix.h"
+
+typedef struct grpc_pollset_set {
+ gpr_mu mu;
+
+ size_t pollset_count;
+ size_t pollset_capacity;
+ grpc_pollset **pollsets;
+
+ size_t fd_count;
+ size_t fd_capacity;
+ grpc_fd **fds;
+} grpc_pollset_set;
+
+void grpc_pollset_set_add_fd(grpc_pollset_set *pollset_set, grpc_fd *fd);
+void grpc_pollset_set_del_fd(grpc_pollset_set *pollset_set, grpc_fd *fd);
+
+#endif /* GRPC_INTERNAL_CORE_IOMGR_POLLSET_WINDOWS_H */
diff --git a/src/core/iomgr/pollset_set_windows.c b/src/core/iomgr/pollset_set_windows.c
new file mode 100644
index 0000000000..45f8c844db
--- /dev/null
+++ b/src/core/iomgr/pollset_set_windows.c
@@ -0,0 +1,49 @@
+/*
+ *
+ * Copyright 2015, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include <grpc/support/port_platform.h>
+
+#ifdef GPR_WINSOCK_SOCKET
+
+#include "src/core/iomgr/pollset_set.h"
+
+void grpc_pollset_set_init(grpc_pollset_set *pollset_set) {
+}
+
+void grpc_pollset_set_destroy(grpc_pollset_set *pollset_set) {
+}
+
+void grpc_pollset_set_add_pollset(grpc_pollset_set *pollset_set, grpc_pollset *pollset) {
+}
+
+#endif /* GPR_WINSOCK_SOCKET */
diff --git a/src/core/iomgr/pollset_set_windows.h b/src/core/iomgr/pollset_set_windows.h
new file mode 100644
index 0000000000..8ec6495d9a
--- /dev/null
+++ b/src/core/iomgr/pollset_set_windows.h
@@ -0,0 +1,40 @@
+/*
+ *
+ * Copyright 2015, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef GRPC_INTERNAL_CORE_IOMGR_POLLSET_SET_WINDOWS_H
+#define GRPC_INTERNAL_CORE_IOMGR_POLLSET_SET_WINDOWS_H
+
+typedef struct grpc_pollset_set {
+} grpc_pollset_set;
+
+#endif /* GRPC_INTERNAL_CORE_IOMGR_POLLSET_WINDOWS_H */
diff --git a/src/core/iomgr/tcp_client.h b/src/core/iomgr/tcp_client.h
index 2e91497fb7..e1fdf235ec 100644
--- a/src/core/iomgr/tcp_client.h
+++ b/src/core/iomgr/tcp_client.h
@@ -35,6 +35,7 @@
#define GRPC_INTERNAL_CORE_IOMGR_TCP_CLIENT_H
#include "src/core/iomgr/endpoint.h"
+#include "src/core/iomgr/pollset_set.h"
#include "src/core/iomgr/sockaddr.h"
#include <grpc/support/time.h>
@@ -42,7 +43,8 @@
cb with arg and the completed connection when done (or call cb with arg and
NULL on failure) */
void grpc_tcp_client_connect(void (*cb)(void *arg, grpc_endpoint *tcp),
- void *arg, const struct sockaddr *addr,
- int addr_len, gpr_timespec deadline);
+ void *arg, grpc_pollset_set *interested_parties,
+ const struct sockaddr *addr, int addr_len,
+ gpr_timespec deadline);
#endif /* GRPC_INTERNAL_CORE_IOMGR_TCP_CLIENT_H */
diff --git a/src/core/iomgr/tcp_client_posix.c b/src/core/iomgr/tcp_client_posix.c
index 2401fe00e4..2a81cf56a4 100644
--- a/src/core/iomgr/tcp_client_posix.c
+++ b/src/core/iomgr/tcp_client_posix.c
@@ -152,6 +152,7 @@ static void on_writable(void *acp, int success) {
goto finish;
}
} else {
+ gpr_log(GPR_DEBUG, "connected");
ep = grpc_tcp_create(ac->fd, GRPC_TCP_DEFAULT_READ_SLICE_SIZE);
goto finish;
}
@@ -177,14 +178,16 @@ finish:
}
void grpc_tcp_client_connect(void (*cb)(void *arg, grpc_endpoint *ep),
- void *arg, const struct sockaddr *addr,
- int addr_len, gpr_timespec deadline) {
+ void *arg, grpc_pollset_set *interested_parties,
+ const struct sockaddr *addr, int addr_len,
+ gpr_timespec deadline) {
int fd;
grpc_dualstack_mode dsmode;
int err;
async_connect *ac;
struct sockaddr_in6 addr6_v4mapped;
struct sockaddr_in addr4_copy;
+ grpc_fd *fdobj;
/* Use dualstack sockets where available. */
if (grpc_sockaddr_to_v4mapped(addr, &addr6_v4mapped)) {
@@ -207,20 +210,25 @@ void grpc_tcp_client_connect(void (*cb)(void *arg, grpc_endpoint *ep),
return;
}
+ gpr_log(GPR_DEBUG, "connecting fd %d", fd);
+
do {
err = connect(fd, addr, addr_len);
} while (err < 0 && errno == EINTR);
+ fdobj = grpc_fd_create(fd);
+ grpc_pollset_set_add_fd(interested_parties, fdobj);
+
if (err >= 0) {
gpr_log(GPR_DEBUG, "instant connect");
cb(arg,
- grpc_tcp_create(grpc_fd_create(fd), GRPC_TCP_DEFAULT_READ_SLICE_SIZE));
+ grpc_tcp_create(fdobj, GRPC_TCP_DEFAULT_READ_SLICE_SIZE));
return;
}
if (errno != EWOULDBLOCK && errno != EINPROGRESS) {
gpr_log(GPR_ERROR, "connect error: %s", strerror(errno));
- close(fd);
+ grpc_fd_orphan(fdobj, NULL, NULL);
cb(arg, NULL);
return;
}
@@ -228,7 +236,7 @@ void grpc_tcp_client_connect(void (*cb)(void *arg, grpc_endpoint *ep),
ac = gpr_malloc(sizeof(async_connect));
ac->cb = cb;
ac->cb_arg = arg;
- ac->fd = grpc_fd_create(fd);
+ ac->fd = fdobj;
gpr_mu_init(&ac->mu);
ac->refs = 2;
ac->write_closure.cb = on_writable;
diff --git a/src/core/iomgr/tcp_client_windows.c b/src/core/iomgr/tcp_client_windows.c
index cf5174327d..f5d0ceccb9 100644
--- a/src/core/iomgr/tcp_client_windows.c
+++ b/src/core/iomgr/tcp_client_windows.c
@@ -138,9 +138,10 @@ static void on_connect(void *acp, int from_iocp) {
/* Tries to issue one async connection, then schedules both an IOCP
notification request for the connection, and one timeout alert. */
-void grpc_tcp_client_connect(void(*cb)(void *arg, grpc_endpoint *tcp),
- void *arg, const struct sockaddr *addr,
- int addr_len, gpr_timespec deadline) {
+void grpc_tcp_client_connect(void (*cb)(void *arg, grpc_endpoint *tcp),
+ void *arg, grpc_pollset_set *interested_parties,
+ const struct sockaddr *addr, int addr_len,
+ gpr_timespec deadline) {
SOCKET sock = INVALID_SOCKET;
BOOL success;
int status;
diff --git a/src/core/iomgr/tcp_server_posix.c b/src/core/iomgr/tcp_server_posix.c
index d1cd8a769c..002756f115 100644
--- a/src/core/iomgr/tcp_server_posix.c
+++ b/src/core/iomgr/tcp_server_posix.c
@@ -99,13 +99,14 @@ struct grpc_tcp_server {
void *cb_arg;
gpr_mu mu;
- gpr_cv cv;
/* active port count: how many ports are actually still listening */
size_t active_ports;
/* destroyed port count: how many ports are completely destroyed */
size_t destroyed_ports;
+ int shutdown;
+
/* all listening ports */
server_port *ports;
size_t nports;
@@ -114,14 +115,17 @@ struct grpc_tcp_server {
/* shutdown callback */
void (*shutdown_complete)(void *);
void *shutdown_complete_arg;
+
+ grpc_pollset **pollsets;
+ size_t pollset_count;
};
grpc_tcp_server *grpc_tcp_server_create(void) {
grpc_tcp_server *s = gpr_malloc(sizeof(grpc_tcp_server));
gpr_mu_init(&s->mu);
- gpr_cv_init(&s->cv);
s->active_ports = 0;
s->destroyed_ports = 0;
+ s->shutdown = 0;
s->cb = NULL;
s->cb_arg = NULL;
s->ports = gpr_malloc(sizeof(server_port) * INIT_PORT_CAP);
@@ -134,7 +138,6 @@ static void finish_shutdown(grpc_tcp_server *s) {
s->shutdown_complete(s->shutdown_complete_arg);
gpr_mu_destroy(&s->mu);
- gpr_cv_destroy(&s->cv);
gpr_free(s->ports);
gpr_free(s);
@@ -154,28 +157,17 @@ static void destroyed_port(void *server, int success) {
static void dont_care_about_shutdown_completion(void *ignored) {}
-void grpc_tcp_server_destroy(
- grpc_tcp_server *s, void (*shutdown_complete)(void *shutdown_complete_arg),
- void *shutdown_complete_arg) {
+static void deactivated_all_ports(grpc_tcp_server *s) {
size_t i;
- gpr_mu_lock(&s->mu);
- s->shutdown_complete = shutdown_complete
- ? shutdown_complete
- : dont_care_about_shutdown_completion;
- s->shutdown_complete_arg = shutdown_complete_arg;
+ /* delete ALL the things */
+ gpr_mu_lock(&s->mu);
- /* shutdown all fd's */
- for (i = 0; i < s->nports; i++) {
- grpc_fd_shutdown(s->ports[i].emfd);
- }
- /* wait while that happens */
- /* TODO(ctiller): make this asynchronous also */
- while (s->active_ports) {
- gpr_cv_wait(&s->cv, &s->mu, gpr_inf_future);
+ if (!s->shutdown) {
+ gpr_mu_unlock(&s->mu);
+ return;
}
- /* delete ALL the things */
if (s->nports) {
for (i = 0; i < s->nports; i++) {
server_port *sp = &s->ports[i];
@@ -191,6 +183,32 @@ void grpc_tcp_server_destroy(
}
}
+void grpc_tcp_server_destroy(
+ grpc_tcp_server *s, void (*shutdown_complete)(void *shutdown_complete_arg),
+ void *shutdown_complete_arg) {
+ size_t i;
+ gpr_mu_lock(&s->mu);
+
+ GPR_ASSERT(!s->shutdown);
+ s->shutdown = 1;
+
+ s->shutdown_complete = shutdown_complete
+ ? shutdown_complete
+ : dont_care_about_shutdown_completion;
+ s->shutdown_complete_arg = shutdown_complete_arg;
+
+ /* shutdown all fd's */
+ if (s->active_ports) {
+ for (i = 0; i < s->nports; i++) {
+ grpc_fd_shutdown(s->ports[i].emfd);
+ }
+ gpr_mu_unlock(&s->mu);
+ } else {
+ gpr_mu_unlock(&s->mu);
+ deactivated_all_ports(s);
+ }
+}
+
/* get max listen queue size on linux */
static void init_max_accept_queue_size(void) {
int n = SOMAXCONN;
@@ -272,6 +290,8 @@ error:
/* event manager callback when reads are ready */
static void on_read(void *arg, int success) {
server_port *sp = arg;
+ grpc_fd *fdobj;
+ size_t i;
if (!success) {
goto error;
@@ -299,9 +319,16 @@ static void on_read(void *arg, int success) {
grpc_set_socket_no_sigpipe_if_possible(fd);
+ fdobj = grpc_fd_create(fd);
+ /* TODO(ctiller): revise this when we have server-side sharding
+ of channels -- we certainly should not be automatically adding every
+ incoming channel to every pollset owned by the server */
+ for (i = 0; i < sp->server->pollset_count; i++) {
+ grpc_pollset_add_fd(sp->server->pollsets[i], fdobj);
+ }
sp->server->cb(
sp->server->cb_arg,
- grpc_tcp_create(grpc_fd_create(fd), GRPC_TCP_DEFAULT_READ_SLICE_SIZE));
+ grpc_tcp_create(fdobj, GRPC_TCP_DEFAULT_READ_SLICE_SIZE));
}
abort();
@@ -309,9 +336,11 @@ static void on_read(void *arg, int success) {
error:
gpr_mu_lock(&sp->server->mu);
if (0 == --sp->server->active_ports) {
- gpr_cv_broadcast(&sp->server->cv);
+ gpr_mu_unlock(&sp->server->mu);
+ deactivated_all_ports(sp->server);
+ } else {
+ gpr_mu_unlock(&sp->server->mu);
}
- gpr_mu_unlock(&sp->server->mu);
}
static int add_socket_to_server(grpc_tcp_server *s, int fd,
@@ -436,6 +465,8 @@ void grpc_tcp_server_start(grpc_tcp_server *s, grpc_pollset **pollsets,
GPR_ASSERT(s->active_ports == 0);
s->cb = cb;
s->cb_arg = cb_arg;
+ s->pollsets = pollsets;
+ s->pollset_count = pollset_count;
for (i = 0; i < s->nports; i++) {
for (j = 0; j < pollset_count; j++) {
grpc_pollset_add_fd(pollsets[j], s->ports[i].emfd);
diff --git a/src/core/security/credentials.c b/src/core/security/credentials.c
index f6366f0750..e89dfee02e 100644
--- a/src/core/security/credentials.c
+++ b/src/core/security/credentials.c
@@ -470,6 +470,7 @@ grpc_credentials *grpc_jwt_credentials_create(const char *json_key,
from an http service. */
typedef void (*grpc_fetch_oauth2_func)(grpc_credentials_metadata_request *req,
+ grpc_pollset_set *interested_parties,
grpc_httpcli_response_cb response_cb,
gpr_timespec deadline);
@@ -479,6 +480,7 @@ typedef struct {
grpc_mdctx *md_ctx;
grpc_mdelem *access_token_md;
gpr_timespec token_expiration;
+ grpc_pollset_set pollset_set;
grpc_fetch_oauth2_func fetch_func;
} grpc_oauth2_token_fetcher_credentials;
@@ -490,6 +492,7 @@ static void oauth2_token_fetcher_destroy(grpc_credentials *creds) {
}
gpr_mu_destroy(&c->mu);
grpc_mdctx_unref(c->md_ctx);
+ grpc_pollset_set_destroy(&c->pollset_set);
gpr_free(c);
}
@@ -637,6 +640,7 @@ static void oauth2_token_fetcher_get_request_metadata(
} else {
c->fetch_func(
grpc_credentials_metadata_request_create(creds, cb, user_data),
+ &c->pollset_set,
on_oauth2_token_fetcher_http_response,
gpr_time_add(gpr_now(), refresh_threshold));
}
@@ -651,6 +655,7 @@ static void init_oauth2_token_fetcher(grpc_oauth2_token_fetcher_credentials *c,
c->md_ctx = grpc_mdctx_create();
c->token_expiration = gpr_inf_past;
c->fetch_func = fetch_func;
+ grpc_pollset_set_init(&c->pollset_set);
}
static grpc_mdctx *oauth2_token_fetcher_get_metadata_context(
@@ -670,6 +675,7 @@ static grpc_credentials_vtable compute_engine_vtable = {
static void compute_engine_fetch_oauth2(
grpc_credentials_metadata_request *metadata_req,
+ grpc_pollset_set *interested_parties,
grpc_httpcli_response_cb response_cb, gpr_timespec deadline) {
grpc_httpcli_header header = {"Metadata-Flavor", "Google"};
grpc_httpcli_request request;
@@ -678,7 +684,7 @@ static void compute_engine_fetch_oauth2(
request.path = GRPC_COMPUTE_ENGINE_METADATA_TOKEN_PATH;
request.hdr_count = 1;
request.hdrs = &header;
- grpc_httpcli_get(&request, deadline, response_cb, metadata_req);
+ grpc_httpcli_get(&request, deadline, interested_parties, response_cb, metadata_req);
}
grpc_credentials *grpc_compute_engine_credentials_create(void) {
@@ -714,7 +720,7 @@ static grpc_credentials_vtable service_account_vtable = {
static void service_account_fetch_oauth2(
grpc_credentials_metadata_request *metadata_req,
- grpc_httpcli_response_cb response_cb, gpr_timespec deadline) {
+ grpc_pollset_set *interested_parties, grpc_httpcli_response_cb response_cb, gpr_timespec deadline) {
grpc_service_account_credentials *c =
(grpc_service_account_credentials *)metadata_req->creds;
grpc_httpcli_header header = {"Content-Type",
@@ -739,7 +745,7 @@ static void service_account_fetch_oauth2(
request.hdr_count = 1;
request.hdrs = &header;
request.use_ssl = 1;
- grpc_httpcli_post(&request, body, strlen(body), deadline, response_cb,
+ grpc_httpcli_post(&request, body, strlen(body), deadline, &c->base.pollset_set, response_cb,
metadata_req);
gpr_free(body);
gpr_free(jwt);
@@ -788,6 +794,7 @@ static grpc_credentials_vtable refresh_token_vtable = {
static void refresh_token_fetch_oauth2(
grpc_credentials_metadata_request *metadata_req,
+ grpc_pollset_set *interested_parties,
grpc_httpcli_response_cb response_cb, gpr_timespec deadline) {
grpc_refresh_token_credentials *c =
(grpc_refresh_token_credentials *)metadata_req->creds;
@@ -804,7 +811,7 @@ static void refresh_token_fetch_oauth2(
request.hdr_count = 1;
request.hdrs = &header;
request.use_ssl = 1;
- grpc_httpcli_post(&request, body, strlen(body), deadline, response_cb,
+ grpc_httpcli_post(&request, body, strlen(body), deadline, interested_parties, response_cb,
metadata_req);
gpr_free(body);
}
diff --git a/src/core/security/credentials.h b/src/core/security/credentials.h
index 87c773e49a..4854641401 100644
--- a/src/core/security/credentials.h
+++ b/src/core/security/credentials.h
@@ -105,7 +105,6 @@ typedef struct {
grpc_credentials *c, const char *target, const grpc_channel_args *args,
grpc_credentials *request_metadata_creds,
grpc_channel_security_connector **sc, grpc_channel_args **new_args);
-
} grpc_credentials_vtable;
struct grpc_credentials {
diff --git a/src/core/security/google_default_credentials.c b/src/core/security/google_default_credentials.c
index 0e4b9fc9d3..5220bae6ff 100644
--- a/src/core/security/google_default_credentials.c
+++ b/src/core/security/google_default_credentials.c
@@ -60,8 +60,7 @@ static void init_default_credentials(void) {
}
typedef struct {
- gpr_cv cv;
- gpr_mu mu;
+ grpc_pollset pollset;
int is_done;
int success;
} compute_engine_detector;
@@ -82,22 +81,22 @@ static void on_compute_engine_detection_http_response(
}
}
}
- gpr_mu_lock(&detector->mu);
+ gpr_mu_lock(GRPC_POLLSET_MU(&detector->pollset));
detector->is_done = 1;
- gpr_mu_unlock(&detector->mu);
- gpr_cv_signal(&detector->cv);
+ grpc_pollset_kick(&detector->pollset);
+ gpr_mu_unlock(GRPC_POLLSET_MU(&detector->pollset));
}
static int is_stack_running_on_compute_engine(void) {
compute_engine_detector detector;
grpc_httpcli_request request;
+ grpc_pollset_set pollset_set;
/* The http call is local. If it takes more than one sec, it is for sure not
on compute engine. */
gpr_timespec max_detection_delay = {1, 0};
- gpr_mu_init(&detector.mu);
- gpr_cv_init(&detector.cv);
+ grpc_pollset_init(&detector.pollset);
detector.is_done = 0;
detector.success = 0;
@@ -105,19 +104,24 @@ static int is_stack_running_on_compute_engine(void) {
request.host = GRPC_COMPUTE_ENGINE_DETECTION_HOST;
request.path = "/";
+ grpc_pollset_set_init(&pollset_set);
+ grpc_pollset_set_add_pollset(&pollset_set, &detector.pollset);
+
grpc_httpcli_get(&request, gpr_time_add(gpr_now(), max_detection_delay),
- on_compute_engine_detection_http_response, &detector);
+ &pollset_set, on_compute_engine_detection_http_response,
+ &detector);
/* Block until we get the response. This is not ideal but this should only be
called once for the lifetime of the process by the default credentials. */
- gpr_mu_lock(&detector.mu);
+ gpr_mu_lock(GRPC_POLLSET_MU(&detector.pollset));
while (!detector.is_done) {
- gpr_cv_wait(&detector.cv, &detector.mu, gpr_inf_future);
+ grpc_pollset_work(&detector.pollset, gpr_inf_future);
}
- gpr_mu_unlock(&detector.mu);
+ gpr_mu_unlock(GRPC_POLLSET_MU(&detector.pollset));
+
+ grpc_pollset_set_destroy(&pollset_set);
+ grpc_pollset_destroy(&detector.pollset);
- gpr_mu_destroy(&detector.mu);
- gpr_cv_destroy(&detector.cv);
return detector.success;
}
diff --git a/src/core/surface/call.c b/src/core/surface/call.c
index 50df36cae9..d403eeede6 100644
--- a/src/core/surface/call.c
+++ b/src/core/surface/call.c
@@ -588,6 +588,7 @@ static void call_on_done_send(void *pc, int success) {
lock(call);
if (call->last_send_contains & (1 << GRPC_IOREQ_SEND_INITIAL_METADATA)) {
finish_ioreq_op(call, GRPC_IOREQ_SEND_INITIAL_METADATA, success);
+ call->write_state = WRITE_STATE_STARTED;
}
if (call->last_send_contains & (1 << GRPC_IOREQ_SEND_MESSAGE)) {
finish_ioreq_op(call, GRPC_IOREQ_SEND_MESSAGE, success);
@@ -596,6 +597,10 @@ static void call_on_done_send(void *pc, int success) {
finish_ioreq_op(call, GRPC_IOREQ_SEND_TRAILING_METADATA, success);
finish_ioreq_op(call, GRPC_IOREQ_SEND_STATUS, success);
finish_ioreq_op(call, GRPC_IOREQ_SEND_CLOSE, 1);
+ call->write_state = WRITE_STATE_WRITE_CLOSED;
+ }
+ if (!success) {
+ call->write_state = WRITE_STATE_WRITE_CLOSED;
}
call->last_send_contains = 0;
call->sending = 0;
@@ -810,7 +815,6 @@ static int fill_send_ops(grpc_call *call, grpc_transport_op *op) {
op->send_ops = &call->send_ops;
op->bind_pollset = grpc_cq_pollset(call->cq);
call->last_send_contains |= 1 << GRPC_IOREQ_SEND_INITIAL_METADATA;
- call->write_state = WRITE_STATE_STARTED;
call->send_initial_metadata_count = 0;
/* fall through intended */
case WRITE_STATE_STARTED:
@@ -826,7 +830,6 @@ static int fill_send_ops(grpc_call *call, grpc_transport_op *op) {
op->is_last_send = 1;
op->send_ops = &call->send_ops;
call->last_send_contains |= 1 << GRPC_IOREQ_SEND_CLOSE;
- call->write_state = WRITE_STATE_WRITE_CLOSED;
if (!call->is_client) {
/* send trailing metadata */
data = call->request_data[GRPC_IOREQ_SEND_TRAILING_METADATA];
diff --git a/src/core/surface/channel_create.c b/src/core/surface/channel_create.c
index daa8d3a7c6..b2d3a1923b 100644
--- a/src/core/surface/channel_create.c
+++ b/src/core/surface/channel_create.c
@@ -125,9 +125,10 @@ static int maybe_try_next_resolved(request *r) {
if (!r->resolved) return 0;
if (r->resolved_index == r->resolved->naddrs) return 0;
addr = &r->resolved->addrs[r->resolved_index++];
- grpc_tcp_client_connect(on_connect, r, (struct sockaddr *)&addr->addr,
- addr->len,
- grpc_client_setup_request_deadline(r->cs_request));
+ grpc_tcp_client_connect(
+ on_connect, r, grpc_client_setup_get_interested_parties(r->cs_request),
+ (struct sockaddr *)&addr->addr, addr->len,
+ grpc_client_setup_request_deadline(r->cs_request));
return 1;
}
diff --git a/src/core/surface/secure_channel_create.c b/src/core/surface/secure_channel_create.c
index 3e331293b5..73f4d51855 100644
--- a/src/core/surface/secure_channel_create.c
+++ b/src/core/surface/secure_channel_create.c
@@ -140,9 +140,10 @@ static int maybe_try_next_resolved(request *r) {
if (!r->resolved) return 0;
if (r->resolved_index == r->resolved->naddrs) return 0;
addr = &r->resolved->addrs[r->resolved_index++];
- grpc_tcp_client_connect(on_connect, r, (struct sockaddr *)&addr->addr,
- addr->len,
- grpc_client_setup_request_deadline(r->cs_request));
+ grpc_tcp_client_connect(
+ on_connect, r, grpc_client_setup_get_interested_parties(r->cs_request),
+ (struct sockaddr *)&addr->addr, addr->len,
+ grpc_client_setup_request_deadline(r->cs_request));
return 1;
}
diff --git a/src/core/transport/transport.c b/src/core/transport/transport.c
index d9a1319c42..b81950d303 100644
--- a/src/core/transport/transport.c
+++ b/src/core/transport/transport.c
@@ -86,6 +86,14 @@ void grpc_transport_setup_initiate(grpc_transport_setup *setup) {
setup->vtable->initiate(setup);
}
+void grpc_transport_setup_add_interested_party(grpc_transport_setup *setup, grpc_pollset *pollset) {
+ setup->vtable->add_interested_party(setup, pollset);
+}
+
+void grpc_transport_setup_del_interested_party(grpc_transport_setup *setup, grpc_pollset *pollset) {
+ setup->vtable->del_interested_party(setup, pollset);
+}
+
void grpc_transport_op_finish_with_failure(grpc_transport_op *op) {
if (op->send_ops) {
op->on_done_send(op->send_user_data, 0);
diff --git a/src/core/transport/transport.h b/src/core/transport/transport.h
index 7a389ea393..4dcd4467e3 100644
--- a/src/core/transport/transport.h
+++ b/src/core/transport/transport.h
@@ -37,6 +37,7 @@
#include <stddef.h>
#include "src/core/iomgr/pollset.h"
+#include "src/core/iomgr/pollset_set.h"
#include "src/core/transport/stream_op.h"
/* forward declarations */
@@ -194,6 +195,8 @@ typedef struct grpc_transport_setup_vtable grpc_transport_setup_vtable;
struct grpc_transport_setup_vtable {
void (*initiate)(grpc_transport_setup *setup);
+ void (*add_interested_party)(grpc_transport_setup *setup, grpc_pollset *pollset);
+ void (*del_interested_party)(grpc_transport_setup *setup, grpc_pollset *pollset);
void (*cancel)(grpc_transport_setup *setup);
};
@@ -210,6 +213,10 @@ struct grpc_transport_setup {
This *may* be implemented as a no-op if the setup process monitors something
continuously. */
void grpc_transport_setup_initiate(grpc_transport_setup *setup);
+
+void grpc_transport_setup_add_interested_party(grpc_transport_setup *setup, grpc_pollset *pollset);
+void grpc_transport_setup_del_interested_party(grpc_transport_setup *setup, grpc_pollset *pollset);
+
/* Cancel transport setup. After this returns, no new transports should be
created, and all pending transport setup callbacks should be completed.
After this call completes, setup should be considered invalid (this can be
diff --git a/test/core/end2end/dualstack_socket_test.c b/test/core/end2end/dualstack_socket_test.c
index be3c7ca17f..b54b8ecb3c 100644
--- a/test/core/end2end/dualstack_socket_test.c
+++ b/test/core/end2end/dualstack_socket_test.c
@@ -62,12 +62,10 @@ void test_connect(const char *server_host, const char *client_host, int port,
char *server_hostport;
grpc_channel *client;
grpc_server *server;
- grpc_completion_queue *client_cq;
- grpc_completion_queue *server_cq;
+ grpc_completion_queue *cq;
grpc_call *c;
grpc_call *s;
- cq_verifier *v_client;
- cq_verifier *v_server;
+ cq_verifier *cqv;
gpr_timespec deadline;
int got_port;
grpc_op ops[6];
@@ -93,9 +91,9 @@ void test_connect(const char *server_host, const char *client_host, int port,
grpc_call_details_init(&call_details);
/* Create server. */
- server_cq = grpc_completion_queue_create();
+ cq = grpc_completion_queue_create();
server = grpc_server_create(NULL);
- grpc_server_register_completion_queue(server, server_cq);
+ grpc_server_register_completion_queue(server, cq);
GPR_ASSERT((got_port = grpc_server_add_http2_port(server, server_hostport)) >
0);
if (port == 0) {
@@ -104,13 +102,11 @@ void test_connect(const char *server_host, const char *client_host, int port,
GPR_ASSERT(port == got_port);
}
grpc_server_start(server);
- v_server = cq_verifier_create(server_cq);
+ cqv = cq_verifier_create(cq);
/* Create client. */
gpr_join_host_port(&client_hostport, client_host, port);
- client_cq = grpc_completion_queue_create();
client = grpc_channel_create(client_hostport, NULL);
- v_client = cq_verifier_create(client_cq);
gpr_log(GPR_INFO, "Testing with server=%s client=%s (expecting %s)",
server_hostport, client_hostport, expect_ok ? "success" : "failure");
@@ -128,7 +124,7 @@ void test_connect(const char *server_host, const char *client_host, int port,
}
/* Send a trivial request. */
- c = grpc_channel_create_call(client, client_cq, "/foo", "foo.test.google.fr",
+ c = grpc_channel_create_call(client, cq, "/foo", "foo.test.google.fr",
deadline);
GPR_ASSERT(c);
@@ -153,10 +149,10 @@ void test_connect(const char *server_host, const char *client_host, int port,
/* Check for a successful request. */
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(server, &s, &call_details,
- &request_metadata_recv, server_cq,
- server_cq, tag(101)));
- cq_expect_completion(v_server, tag(101), 1);
- cq_verify(v_server);
+ &request_metadata_recv, cq,
+ cq, tag(101)));
+ cq_expect_completion(cqv, tag(101), 1);
+ cq_verify(cqv);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -173,11 +169,9 @@ void test_connect(const char *server_host, const char *client_host, int port,
GPR_ASSERT(GRPC_CALL_OK ==
grpc_call_start_batch(s, ops, op - ops, tag(102)));
- cq_expect_completion(v_server, tag(102), 1);
- cq_verify(v_server);
-
- cq_expect_completion(v_client, tag(1), 1);
- cq_verify(v_client);
+ cq_expect_completion(cqv, tag(102), 1);
+ cq_expect_completion(cqv, tag(1), 1);
+ cq_verify(cqv);
GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED);
GPR_ASSERT(0 == strcmp(details, "xyz"));
@@ -188,29 +182,25 @@ void test_connect(const char *server_host, const char *client_host, int port,
grpc_call_destroy(s);
} else {
/* Check for a failed connection. */
- cq_expect_completion(v_client, tag(1), 1);
- cq_verify(v_client);
+ cq_expect_completion(cqv, tag(1), 1);
+ cq_verify(cqv);
GPR_ASSERT(status == GRPC_STATUS_DEADLINE_EXCEEDED);
}
grpc_call_destroy(c);
- cq_verifier_destroy(v_client);
- cq_verifier_destroy(v_server);
+ cq_verifier_destroy(cqv);
/* Destroy client. */
grpc_channel_destroy(client);
- grpc_completion_queue_shutdown(client_cq);
- drain_cq(client_cq);
- grpc_completion_queue_destroy(client_cq);
/* Destroy server. */
grpc_server_shutdown(server);
grpc_server_destroy(server);
- grpc_completion_queue_shutdown(server_cq);
- drain_cq(server_cq);
- grpc_completion_queue_destroy(server_cq);
+ grpc_completion_queue_shutdown(cq);
+ drain_cq(cq);
+ grpc_completion_queue_destroy(cq);
}
int main(int argc, char **argv) {
diff --git a/test/core/end2end/end2end_tests.h b/test/core/end2end/end2end_tests.h
index a61c725aa2..8996bacd24 100644
--- a/test/core/end2end/end2end_tests.h
+++ b/test/core/end2end/end2end_tests.h
@@ -44,8 +44,7 @@ typedef struct grpc_end2end_test_config grpc_end2end_test_config;
#define FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS 4
struct grpc_end2end_test_fixture {
- grpc_completion_queue *server_cq;
- grpc_completion_queue *client_cq;
+ grpc_completion_queue *cq;
grpc_server *server;
grpc_channel *client;
void *fixture_data;
diff --git a/test/core/end2end/fixtures/chttp2_fake_security.c b/test/core/end2end/fixtures/chttp2_fake_security.c
index 5323e29e82..7e98d729b3 100644
--- a/test/core/end2end/fixtures/chttp2_fake_security.c
+++ b/test/core/end2end/fixtures/chttp2_fake_security.c
@@ -60,8 +60,7 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack(
gpr_join_host_port(&ffd->localaddr, "localhost", port);
f.fixture_data = ffd;
- f.client_cq = grpc_completion_queue_create();
- f.server_cq = grpc_completion_queue_create();
+ f.cq = grpc_completion_queue_create();
return f;
}
@@ -83,7 +82,7 @@ static void chttp2_init_server_secure_fullstack(
grpc_server_destroy(f->server);
}
f->server = grpc_server_create(server_args);
- grpc_server_register_completion_queue(f->server, f->server_cq);
+ grpc_server_register_completion_queue(f->server, f->cq);
GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr, server_creds));
grpc_server_credentials_release(server_creds);
grpc_server_start(f->server);
diff --git a/test/core/end2end/fixtures/chttp2_fullstack.c b/test/core/end2end/fixtures/chttp2_fullstack.c
index f92b40efeb..b83e227a89 100644
--- a/test/core/end2end/fixtures/chttp2_fullstack.c
+++ b/test/core/end2end/fixtures/chttp2_fullstack.c
@@ -65,8 +65,7 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack(
gpr_join_host_port(&ffd->localaddr, "localhost", port);
f.fixture_data = ffd;
- f.client_cq = grpc_completion_queue_create();
- f.server_cq = grpc_completion_queue_create();
+ f.cq = grpc_completion_queue_create();
return f;
}
@@ -84,7 +83,7 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture *f,
grpc_server_destroy(f->server);
}
f->server = grpc_server_create(server_args);
- grpc_server_register_completion_queue(f->server, f->server_cq);
+ grpc_server_register_completion_queue(f->server, f->cq);
GPR_ASSERT(grpc_server_add_http2_port(f->server, ffd->localaddr));
grpc_server_start(f->server);
}
diff --git a/test/core/end2end/fixtures/chttp2_fullstack_uds_posix.c b/test/core/end2end/fixtures/chttp2_fullstack_uds_posix.c
index 876782df84..1c1751d581 100644
--- a/test/core/end2end/fixtures/chttp2_fullstack_uds_posix.c
+++ b/test/core/end2end/fixtures/chttp2_fullstack_uds_posix.c
@@ -70,8 +70,7 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack(
unique++);
f.fixture_data = ffd;
- f.client_cq = grpc_completion_queue_create();
- f.server_cq = grpc_completion_queue_create();
+ f.cq = grpc_completion_queue_create();
return f;
}
@@ -89,7 +88,7 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture *f,
grpc_server_destroy(f->server);
}
f->server = grpc_server_create(server_args);
- grpc_server_register_completion_queue(f->server, f->server_cq);
+ grpc_server_register_completion_queue(f->server, f->cq);
GPR_ASSERT(grpc_server_add_http2_port(f->server, ffd->localaddr));
grpc_server_start(f->server);
}
diff --git a/test/core/end2end/fixtures/chttp2_simple_ssl_fullstack.c b/test/core/end2end/fixtures/chttp2_simple_ssl_fullstack.c
index 6d1b7b5ff0..e351fb3241 100644
--- a/test/core/end2end/fixtures/chttp2_simple_ssl_fullstack.c
+++ b/test/core/end2end/fixtures/chttp2_simple_ssl_fullstack.c
@@ -63,8 +63,7 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack(
gpr_join_host_port(&ffd->localaddr, "localhost", port);
f.fixture_data = ffd;
- f.client_cq = grpc_completion_queue_create();
- f.server_cq = grpc_completion_queue_create();
+ f.cq = grpc_completion_queue_create();
return f;
}
@@ -86,7 +85,7 @@ static void chttp2_init_server_secure_fullstack(
grpc_server_destroy(f->server);
}
f->server = grpc_server_create(server_args);
- grpc_server_register_completion_queue(f->server, f->server_cq);
+ grpc_server_register_completion_queue(f->server, f->cq);
GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr, server_creds));
grpc_server_credentials_release(server_creds);
grpc_server_start(f->server);
diff --git a/test/core/end2end/fixtures/chttp2_simple_ssl_with_oauth2_fullstack.c b/test/core/end2end/fixtures/chttp2_simple_ssl_with_oauth2_fullstack.c
index 4a15d502a5..8d512635f9 100644
--- a/test/core/end2end/fixtures/chttp2_simple_ssl_with_oauth2_fullstack.c
+++ b/test/core/end2end/fixtures/chttp2_simple_ssl_with_oauth2_fullstack.c
@@ -61,8 +61,7 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack(
gpr_join_host_port(&ffd->localaddr, "localhost", port);
f.fixture_data = ffd;
- f.client_cq = grpc_completion_queue_create();
- f.server_cq = grpc_completion_queue_create();
+ f.cq = grpc_completion_queue_create();
return f;
}
@@ -84,7 +83,7 @@ static void chttp2_init_server_secure_fullstack(
grpc_server_destroy(f->server);
}
f->server = grpc_server_create(server_args);
- grpc_server_register_completion_queue(f->server, f->server_cq);
+ grpc_server_register_completion_queue(f->server, f->cq);
GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr, server_creds));
grpc_server_credentials_release(server_creds);
grpc_server_start(f->server);
diff --git a/test/core/end2end/fixtures/chttp2_socket_pair.c b/test/core/end2end/fixtures/chttp2_socket_pair.c
index 43ebf7eed5..ec7541910e 100644
--- a/test/core/end2end/fixtures/chttp2_socket_pair.c
+++ b/test/core/end2end/fixtures/chttp2_socket_pair.c
@@ -94,8 +94,7 @@ static grpc_end2end_test_fixture chttp2_create_fixture_socketpair(
grpc_end2end_test_fixture f;
memset(&f, 0, sizeof(f));
f.fixture_data = sfd;
- f.client_cq = grpc_completion_queue_create();
- f.server_cq = grpc_completion_queue_create();
+ f.cq = grpc_completion_queue_create();
*sfd = grpc_iomgr_create_endpoint_pair(65536);
@@ -118,7 +117,7 @@ static void chttp2_init_server_socketpair(grpc_end2end_test_fixture *f,
grpc_endpoint_pair *sfd = f->fixture_data;
GPR_ASSERT(!f->server);
f->server = grpc_server_create_from_filters(NULL, 0, server_args);
- grpc_server_register_completion_queue(f->server, f->server_cq);
+ grpc_server_register_completion_queue(f->server, f->cq);
grpc_server_start(f->server);
grpc_create_chttp2_transport(server_setup_transport, f, server_args,
sfd->server, NULL, 0, grpc_mdctx_create(), 0);
diff --git a/test/core/end2end/fixtures/chttp2_socket_pair_one_byte_at_a_time.c b/test/core/end2end/fixtures/chttp2_socket_pair_one_byte_at_a_time.c
index 385d5a4e81..ac5fc40cc8 100644
--- a/test/core/end2end/fixtures/chttp2_socket_pair_one_byte_at_a_time.c
+++ b/test/core/end2end/fixtures/chttp2_socket_pair_one_byte_at_a_time.c
@@ -94,8 +94,7 @@ static grpc_end2end_test_fixture chttp2_create_fixture_socketpair(
grpc_end2end_test_fixture f;
memset(&f, 0, sizeof(f));
f.fixture_data = sfd;
- f.client_cq = grpc_completion_queue_create();
- f.server_cq = grpc_completion_queue_create();
+ f.cq = grpc_completion_queue_create();
*sfd = grpc_iomgr_create_endpoint_pair(1);
@@ -118,7 +117,7 @@ static void chttp2_init_server_socketpair(grpc_end2end_test_fixture *f,
grpc_endpoint_pair *sfd = f->fixture_data;
GPR_ASSERT(!f->server);
f->server = grpc_server_create_from_filters(NULL, 0, server_args);
- grpc_server_register_completion_queue(f->server, f->server_cq);
+ grpc_server_register_completion_queue(f->server, f->cq);
grpc_server_start(f->server);
grpc_create_chttp2_transport(server_setup_transport, f, server_args,
sfd->server, NULL, 0, grpc_mdctx_create(), 0);
diff --git a/test/core/end2end/tests/bad_hostname.c b/test/core/end2end/tests/bad_hostname.c
index e145d2e95b..726bada7bf 100644
--- a/test/core/end2end/tests/bad_hostname.c
+++ b/test/core/end2end/tests/bad_hostname.c
@@ -91,18 +91,15 @@ static void end_test(grpc_end2end_test_fixture *f) {
shutdown_server(f);
shutdown_client(f);
- grpc_completion_queue_shutdown(f->server_cq);
- drain_cq(f->server_cq);
- grpc_completion_queue_destroy(f->server_cq);
- grpc_completion_queue_shutdown(f->client_cq);
- drain_cq(f->client_cq);
- grpc_completion_queue_destroy(f->client_cq);
+ grpc_completion_queue_shutdown(f->cq);
+ drain_cq(f->cq);
+ grpc_completion_queue_destroy(f->cq);
}
static void simple_request_body(grpc_end2end_test_fixture f) {
grpc_call *c;
gpr_timespec deadline = five_seconds_time();
- cq_verifier *v_client = cq_verifier_create(f.client_cq);
+ cq_verifier *cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
grpc_op *op;
grpc_metadata_array initial_metadata_recv;
@@ -113,7 +110,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
char *details = NULL;
size_t details_capacity = 0;
- c = grpc_channel_create_call(f.client, f.client_cq, "/foo",
+ c = grpc_channel_create_call(f.client, f.cq, "/foo",
"slartibartfast.local", deadline);
GPR_ASSERT(c);
@@ -139,8 +136,8 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(c, ops, op - ops, tag(1)));
- cq_expect_completion(v_client, tag(1), 1);
- cq_verify(v_client);
+ cq_expect_completion(cqv, tag(1), 1);
+ cq_verify(cqv);
GPR_ASSERT(status == GRPC_STATUS_UNAUTHENTICATED);
@@ -152,7 +149,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
grpc_call_destroy(c);
- cq_verifier_destroy(v_client);
+ cq_verifier_destroy(cqv);
}
static void test_invoke_simple_request(grpc_end2end_test_config config) {
diff --git a/test/core/end2end/tests/cancel_after_accept.c b/test/core/end2end/tests/cancel_after_accept.c
index 275333897f..db6d0899fe 100644
--- a/test/core/end2end/tests/cancel_after_accept.c
+++ b/test/core/end2end/tests/cancel_after_accept.c
@@ -90,12 +90,9 @@ static void end_test(grpc_end2end_test_fixture *f) {
shutdown_server(f);
shutdown_client(f);
- grpc_completion_queue_shutdown(f->server_cq);
- drain_cq(f->server_cq);
- grpc_completion_queue_destroy(f->server_cq);
- grpc_completion_queue_shutdown(f->client_cq);
- drain_cq(f->client_cq);
- grpc_completion_queue_destroy(f->client_cq);
+ grpc_completion_queue_shutdown(f->cq);
+ drain_cq(f->cq);
+ grpc_completion_queue_destroy(f->cq);
}
/* Cancel after accept, no payload */
@@ -107,8 +104,7 @@ static void test_cancel_after_accept(grpc_end2end_test_config config,
grpc_call *s;
grpc_end2end_test_fixture f = begin_test(config, __FUNCTION__, NULL, NULL);
gpr_timespec deadline = five_seconds_time();
- cq_verifier *v_client = cq_verifier_create(f.client_cq);
- cq_verifier *v_server = cq_verifier_create(f.server_cq);
+ cq_verifier *cqv = cq_verifier_create(f.cq);
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
@@ -126,7 +122,7 @@ static void test_cancel_after_accept(grpc_end2end_test_config config,
grpc_byte_buffer_create(&response_payload_slice, 1);
int was_cancelled = 2;
- c = grpc_channel_create_call(f.client, f.client_cq, "/foo",
+ c = grpc_channel_create_call(f.client, f.cq, "/foo",
"foo.test.google.fr", deadline);
GPR_ASSERT(c);
@@ -158,10 +154,10 @@ static void test_cancel_after_accept(grpc_end2end_test_config config,
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f.server, &s, &call_details,
- &request_metadata_recv, f.server_cq,
- f.server_cq, tag(2)));
- cq_expect_completion(v_server, tag(2), 1);
- cq_verify(v_server);
+ &request_metadata_recv, f.cq,
+ f.cq, tag(2)));
+ cq_expect_completion(cqv, tag(2), 1);
+ cq_verify(cqv);
op = ops;
op->op = GRPC_OP_RECV_MESSAGE;
@@ -180,11 +176,9 @@ static void test_cancel_after_accept(grpc_end2end_test_config config,
GPR_ASSERT(GRPC_CALL_OK == mode.initiate_cancel(c));
- cq_expect_completion(v_server, tag(3), 1);
- cq_verify(v_server);
-
- cq_expect_completion(v_client, tag(1), 1);
- cq_verify(v_client);
+ cq_expect_completion(cqv, tag(3), 1);
+ cq_expect_completion(cqv, tag(1), 1);
+ cq_verify(cqv);
GPR_ASSERT(status == mode.expect_status);
GPR_ASSERT(0 == strcmp(details, mode.expect_details));
@@ -204,8 +198,7 @@ static void test_cancel_after_accept(grpc_end2end_test_config config,
grpc_call_destroy(c);
grpc_call_destroy(s);
- cq_verifier_destroy(v_client);
- cq_verifier_destroy(v_server);
+ cq_verifier_destroy(cqv);
end_test(&f);
config.tear_down_data(&f);
}
diff --git a/test/core/end2end/tests/cancel_after_accept_and_writes_closed.c b/test/core/end2end/tests/cancel_after_accept_and_writes_closed.c
index eaf8b60e98..0162df7d28 100644
--- a/test/core/end2end/tests/cancel_after_accept_and_writes_closed.c
+++ b/test/core/end2end/tests/cancel_after_accept_and_writes_closed.c
@@ -90,12 +90,9 @@ static void end_test(grpc_end2end_test_fixture *f) {
shutdown_server(f);
shutdown_client(f);
- grpc_completion_queue_shutdown(f->server_cq);
- drain_cq(f->server_cq);
- grpc_completion_queue_destroy(f->server_cq);
- grpc_completion_queue_shutdown(f->client_cq);
- drain_cq(f->client_cq);
- grpc_completion_queue_destroy(f->client_cq);
+ grpc_completion_queue_shutdown(f->cq);
+ drain_cq(f->cq);
+ grpc_completion_queue_destroy(f->cq);
}
/* Cancel after accept with a writes closed, no payload */
@@ -107,8 +104,7 @@ static void test_cancel_after_accept_and_writes_closed(
grpc_call *s;
grpc_end2end_test_fixture f = begin_test(config, __FUNCTION__, NULL, NULL);
gpr_timespec deadline = five_seconds_time();
- cq_verifier *v_client = cq_verifier_create(f.client_cq);
- cq_verifier *v_server = cq_verifier_create(f.server_cq);
+ cq_verifier *cqv = cq_verifier_create(f.cq);
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
@@ -126,7 +122,7 @@ static void test_cancel_after_accept_and_writes_closed(
grpc_byte_buffer_create(&response_payload_slice, 1);
int was_cancelled = 2;
- c = grpc_channel_create_call(f.client, f.client_cq, "/foo",
+ c = grpc_channel_create_call(f.client, f.cq, "/foo",
"foo.test.google.fr", deadline);
GPR_ASSERT(c);
@@ -160,10 +156,10 @@ static void test_cancel_after_accept_and_writes_closed(
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f.server, &s, &call_details,
- &request_metadata_recv, f.server_cq,
- f.server_cq, tag(2)));
- cq_expect_completion(v_server, tag(2), 1);
- cq_verify(v_server);
+ &request_metadata_recv, f.cq,
+ f.cq, tag(2)));
+ cq_expect_completion(cqv, tag(2), 1);
+ cq_verify(cqv);
op = ops;
op->op = GRPC_OP_RECV_MESSAGE;
@@ -182,11 +178,9 @@ static void test_cancel_after_accept_and_writes_closed(
GPR_ASSERT(GRPC_CALL_OK == mode.initiate_cancel(c));
- cq_expect_completion(v_server, tag(3), 1);
- cq_verify(v_server);
-
- cq_expect_completion(v_client, tag(1), 1);
- cq_verify(v_client);
+ cq_expect_completion(cqv, tag(3), 1);
+ cq_expect_completion(cqv, tag(1), 1);
+ cq_verify(cqv);
GPR_ASSERT(status == mode.expect_status);
GPR_ASSERT(0 == strcmp(details, mode.expect_details));
@@ -206,8 +200,7 @@ static void test_cancel_after_accept_and_writes_closed(
grpc_call_destroy(c);
grpc_call_destroy(s);
- cq_verifier_destroy(v_client);
- cq_verifier_destroy(v_server);
+ cq_verifier_destroy(cqv);
end_test(&f);
config.tear_down_data(&f);
}
diff --git a/test/core/end2end/tests/cancel_after_invoke.c b/test/core/end2end/tests/cancel_after_invoke.c
index 618d9e97e3..cf12269d00 100644
--- a/test/core/end2end/tests/cancel_after_invoke.c
+++ b/test/core/end2end/tests/cancel_after_invoke.c
@@ -91,12 +91,9 @@ static void end_test(grpc_end2end_test_fixture *f) {
shutdown_server(f);
shutdown_client(f);
- grpc_completion_queue_shutdown(f->server_cq);
- drain_cq(f->server_cq);
- grpc_completion_queue_destroy(f->server_cq);
- grpc_completion_queue_shutdown(f->client_cq);
- drain_cq(f->client_cq);
- grpc_completion_queue_destroy(f->client_cq);
+ grpc_completion_queue_shutdown(f->cq);
+ drain_cq(f->cq);
+ grpc_completion_queue_destroy(f->cq);
}
/* Cancel after invoke, no payload */
@@ -108,7 +105,7 @@ static void test_cancel_after_invoke(grpc_end2end_test_config config,
grpc_end2end_test_fixture f =
begin_test(config, __FUNCTION__, mode, NULL, NULL);
gpr_timespec deadline = five_seconds_time();
- cq_verifier *v_client = cq_verifier_create(f.client_cq);
+ cq_verifier *cqv = cq_verifier_create(f.cq);
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
@@ -121,7 +118,7 @@ static void test_cancel_after_invoke(grpc_end2end_test_config config,
grpc_byte_buffer *request_payload =
grpc_byte_buffer_create(&request_payload_slice, 1);
- c = grpc_channel_create_call(f.client, f.client_cq, "/foo",
+ c = grpc_channel_create_call(f.client, f.cq, "/foo",
"foo.test.google.fr", deadline);
GPR_ASSERT(c);
@@ -155,8 +152,8 @@ static void test_cancel_after_invoke(grpc_end2end_test_config config,
GPR_ASSERT(GRPC_CALL_OK == mode.initiate_cancel(c));
- cq_expect_completion(v_client, tag(1), 1);
- cq_verify(v_client);
+ cq_expect_completion(cqv, tag(1), 1);
+ cq_verify(cqv);
GPR_ASSERT(status == mode.expect_status);
GPR_ASSERT(0 == strcmp(details, mode.expect_details));
@@ -172,7 +169,7 @@ static void test_cancel_after_invoke(grpc_end2end_test_config config,
grpc_call_destroy(c);
- cq_verifier_destroy(v_client);
+ cq_verifier_destroy(cqv);
end_test(&f);
config.tear_down_data(&f);
}
diff --git a/test/core/end2end/tests/cancel_before_invoke.c b/test/core/end2end/tests/cancel_before_invoke.c
index 9c9d6aadcc..19d3badde1 100644
--- a/test/core/end2end/tests/cancel_before_invoke.c
+++ b/test/core/end2end/tests/cancel_before_invoke.c
@@ -89,12 +89,9 @@ static void end_test(grpc_end2end_test_fixture *f) {
shutdown_server(f);
shutdown_client(f);
- grpc_completion_queue_shutdown(f->server_cq);
- drain_cq(f->server_cq);
- grpc_completion_queue_destroy(f->server_cq);
- grpc_completion_queue_shutdown(f->client_cq);
- drain_cq(f->client_cq);
- grpc_completion_queue_destroy(f->client_cq);
+ grpc_completion_queue_shutdown(f->cq);
+ drain_cq(f->cq);
+ grpc_completion_queue_destroy(f->cq);
}
/* Cancel before invoke */
@@ -105,7 +102,7 @@ static void test_cancel_before_invoke(grpc_end2end_test_config config,
grpc_call *c;
grpc_end2end_test_fixture f = begin_test(config, __FUNCTION__, NULL, NULL);
gpr_timespec deadline = five_seconds_time();
- cq_verifier *v_client = cq_verifier_create(f.client_cq);
+ cq_verifier *cqv = cq_verifier_create(f.cq);
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
@@ -118,7 +115,7 @@ static void test_cancel_before_invoke(grpc_end2end_test_config config,
grpc_byte_buffer *request_payload =
grpc_byte_buffer_create(&request_payload_slice, 1);
- c = grpc_channel_create_call(f.client, f.client_cq, "/foo",
+ c = grpc_channel_create_call(f.client, f.cq, "/foo",
"foo.test.google.fr", deadline);
GPR_ASSERT(c);
@@ -152,8 +149,8 @@ static void test_cancel_before_invoke(grpc_end2end_test_config config,
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(c, ops, test_ops, tag(1)));
- cq_expect_completion(v_client, tag(1), 1);
- cq_verify(v_client);
+ cq_expect_completion(cqv, tag(1), 1);
+ cq_verify(cqv);
GPR_ASSERT(status == GRPC_STATUS_CANCELLED);
@@ -168,7 +165,7 @@ static void test_cancel_before_invoke(grpc_end2end_test_config config,
grpc_call_destroy(c);
- cq_verifier_destroy(v_client);
+ cq_verifier_destroy(cqv);
end_test(&f);
config.tear_down_data(&f);
}
diff --git a/test/core/end2end/tests/cancel_in_a_vacuum.c b/test/core/end2end/tests/cancel_in_a_vacuum.c
index 1bc393aba7..679b137521 100644
--- a/test/core/end2end/tests/cancel_in_a_vacuum.c
+++ b/test/core/end2end/tests/cancel_in_a_vacuum.c
@@ -88,12 +88,9 @@ static void end_test(grpc_end2end_test_fixture *f) {
shutdown_server(f);
shutdown_client(f);
- grpc_completion_queue_shutdown(f->server_cq);
- drain_cq(f->server_cq);
- grpc_completion_queue_destroy(f->server_cq);
- grpc_completion_queue_shutdown(f->client_cq);
- drain_cq(f->client_cq);
- grpc_completion_queue_destroy(f->client_cq);
+ grpc_completion_queue_shutdown(f->cq);
+ drain_cq(f->cq);
+ grpc_completion_queue_destroy(f->cq);
}
/* Cancel and do nothing */
@@ -102,9 +99,9 @@ static void test_cancel_in_a_vacuum(grpc_end2end_test_config config,
grpc_call *c;
grpc_end2end_test_fixture f = begin_test(config, __FUNCTION__, NULL, NULL);
gpr_timespec deadline = five_seconds_time();
- cq_verifier *v_client = cq_verifier_create(f.client_cq);
+ cq_verifier *v_client = cq_verifier_create(f.cq);
- c = grpc_channel_create_call(f.client, f.client_cq, "/foo",
+ c = grpc_channel_create_call(f.client, f.cq, "/foo",
"foo.test.google.fr", deadline);
GPR_ASSERT(c);
diff --git a/test/core/end2end/tests/census_simple_request.c b/test/core/end2end/tests/census_simple_request.c
index 2017ab6536..4f6c57c4ed 100644
--- a/test/core/end2end/tests/census_simple_request.c
+++ b/test/core/end2end/tests/census_simple_request.c
@@ -84,12 +84,9 @@ static void end_test(grpc_end2end_test_fixture *f) {
shutdown_server(f);
shutdown_client(f);
- grpc_completion_queue_shutdown(f->server_cq);
- drain_cq(f->server_cq);
- grpc_completion_queue_destroy(f->server_cq);
- grpc_completion_queue_shutdown(f->client_cq);
- drain_cq(f->client_cq);
- grpc_completion_queue_destroy(f->client_cq);
+ grpc_completion_queue_shutdown(f->cq);
+ drain_cq(f->cq);
+ grpc_completion_queue_destroy(f->cq);
}
static void *tag(gpr_intptr t) { return (void *)t; }
@@ -98,8 +95,7 @@ static void test_body(grpc_end2end_test_fixture f) {
grpc_call *c;
grpc_call *s;
gpr_timespec deadline = n_seconds_time(5);
- cq_verifier *v_client = cq_verifier_create(f.client_cq);
- cq_verifier *v_server = cq_verifier_create(f.server_cq);
+ cq_verifier *cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
grpc_op *op;
grpc_metadata_array initial_metadata_recv;
@@ -111,7 +107,7 @@ static void test_body(grpc_end2end_test_fixture f) {
size_t details_capacity = 0;
int was_cancelled = 2;
- c = grpc_channel_create_call(f.client, f.client_cq, "/foo",
+ c = grpc_channel_create_call(f.client, f.cq, "/foo",
"foo.test.google.fr:1234", deadline);
GPR_ASSERT(c);
@@ -139,10 +135,10 @@ static void test_body(grpc_end2end_test_fixture f) {
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f.server, &s, &call_details,
- &request_metadata_recv, f.server_cq,
- f.server_cq, tag(101)));
- cq_expect_completion(v_server, tag(101), 1);
- cq_verify(v_server);
+ &request_metadata_recv, f.cq,
+ f.cq, tag(101)));
+ cq_expect_completion(cqv, tag(101), 1);
+ cq_verify(cqv);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -158,11 +154,9 @@ static void test_body(grpc_end2end_test_fixture f) {
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(s, ops, op - ops, tag(102)));
- cq_expect_completion(v_server, tag(102), 1);
- cq_verify(v_server);
-
- cq_expect_completion(v_client, tag(1), 1);
- cq_verify(v_client);
+ cq_expect_completion(cqv, tag(102), 1);
+ cq_expect_completion(cqv, tag(1), 1);
+ cq_verify(cqv);
GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED);
GPR_ASSERT(0 == strcmp(details, "xyz"));
@@ -179,8 +173,7 @@ static void test_body(grpc_end2end_test_fixture f) {
grpc_call_destroy(c);
grpc_call_destroy(s);
- cq_verifier_destroy(v_client);
- cq_verifier_destroy(v_server);
+ cq_verifier_destroy(cqv);
}
static void test_invoke_request_with_census(
diff --git a/test/core/end2end/tests/disappearing_server.c b/test/core/end2end/tests/disappearing_server.c
index 89fff81dba..9bcc79d34d 100644
--- a/test/core/end2end/tests/disappearing_server.c
+++ b/test/core/end2end/tests/disappearing_server.c
@@ -77,17 +77,13 @@ static void end_test(grpc_end2end_test_fixture *f) {
shutdown_server(f);
shutdown_client(f);
- grpc_completion_queue_shutdown(f->server_cq);
- drain_cq(f->server_cq);
- grpc_completion_queue_destroy(f->server_cq);
- grpc_completion_queue_shutdown(f->client_cq);
- drain_cq(f->client_cq);
- grpc_completion_queue_destroy(f->client_cq);
+ grpc_completion_queue_shutdown(f->cq);
+ drain_cq(f->cq);
+ grpc_completion_queue_destroy(f->cq);
}
static void do_request_and_shutdown_server(grpc_end2end_test_fixture *f,
- cq_verifier *v_client,
- cq_verifier *v_server) {
+ cq_verifier *cqv) {
grpc_call *c;
grpc_call *s;
gpr_timespec deadline = five_seconds_time();
@@ -102,7 +98,7 @@ static void do_request_and_shutdown_server(grpc_end2end_test_fixture *f,
size_t details_capacity = 0;
int was_cancelled = 2;
- c = grpc_channel_create_call(f->client, f->client_cq, "/foo",
+ c = grpc_channel_create_call(f->client, f->cq, "/foo",
"foo.test.google.fr:1234", deadline);
GPR_ASSERT(c);
@@ -130,10 +126,10 @@ static void do_request_and_shutdown_server(grpc_end2end_test_fixture *f,
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f->server, &s, &call_details,
- &request_metadata_recv, f->server_cq,
- f->server_cq, tag(101)));
- cq_expect_completion(v_server, tag(101), 1);
- cq_verify(v_server);
+ &request_metadata_recv, f->cq,
+ f->cq, tag(101)));
+ cq_expect_completion(cqv, tag(101), 1);
+ cq_verify(cqv);
/* should be able to shut down the server early
- and still complete the request */
@@ -153,11 +149,9 @@ static void do_request_and_shutdown_server(grpc_end2end_test_fixture *f,
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(s, ops, op - ops, tag(102)));
- cq_expect_completion(v_server, tag(102), 1);
- cq_verify(v_server);
-
- cq_expect_completion(v_client, tag(1), 1);
- cq_verify(v_client);
+ cq_expect_completion(cqv, tag(102), 1);
+ cq_expect_completion(cqv, tag(1), 1);
+ cq_verify(cqv);
GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED);
GPR_ASSERT(0 == strcmp(details, "xyz"));
@@ -177,23 +171,21 @@ static void do_request_and_shutdown_server(grpc_end2end_test_fixture *f,
static void disappearing_server_test(grpc_end2end_test_config config) {
grpc_end2end_test_fixture f = config.create_fixture(NULL, NULL);
- cq_verifier *v_client = cq_verifier_create(f.client_cq);
- cq_verifier *v_server = cq_verifier_create(f.server_cq);
+ cq_verifier *cqv = cq_verifier_create(f.cq);
gpr_log(GPR_INFO, "%s/%s", __FUNCTION__, config.name);
config.init_client(&f, NULL);
config.init_server(&f, NULL);
- do_request_and_shutdown_server(&f, v_client, v_server);
+ do_request_and_shutdown_server(&f, cqv);
/* now destroy and recreate the server */
config.init_server(&f, NULL);
- do_request_and_shutdown_server(&f, v_client, v_server);
+ do_request_and_shutdown_server(&f, cqv);
- cq_verifier_destroy(v_client);
- cq_verifier_destroy(v_server);
+ cq_verifier_destroy(cqv);
end_test(&f);
config.tear_down_data(&f);
diff --git a/test/core/end2end/tests/early_server_shutdown_finishes_inflight_calls.c b/test/core/end2end/tests/early_server_shutdown_finishes_inflight_calls.c
index 42280a6046..3efbf6add8 100644
--- a/test/core/end2end/tests/early_server_shutdown_finishes_inflight_calls.c
+++ b/test/core/end2end/tests/early_server_shutdown_finishes_inflight_calls.c
@@ -89,12 +89,9 @@ static void end_test(grpc_end2end_test_fixture *f) {
shutdown_server(f);
shutdown_client(f);
- grpc_completion_queue_shutdown(f->server_cq);
- drain_cq(f->server_cq);
- grpc_completion_queue_destroy(f->server_cq);
- grpc_completion_queue_shutdown(f->client_cq);
- drain_cq(f->client_cq);
- grpc_completion_queue_destroy(f->client_cq);
+ grpc_completion_queue_shutdown(f->cq);
+ drain_cq(f->cq);
+ grpc_completion_queue_destroy(f->cq);
}
static void test_early_server_shutdown_finishes_inflight_calls(
@@ -103,8 +100,7 @@ static void test_early_server_shutdown_finishes_inflight_calls(
grpc_call *s;
gpr_timespec deadline = five_seconds_time();
grpc_end2end_test_fixture f = begin_test(config, __FUNCTION__, NULL, NULL);
- cq_verifier *v_client = cq_verifier_create(f.client_cq);
- cq_verifier *v_server = cq_verifier_create(f.server_cq);
+ cq_verifier *cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
grpc_op *op;
grpc_metadata_array initial_metadata_recv;
@@ -116,7 +112,7 @@ static void test_early_server_shutdown_finishes_inflight_calls(
size_t details_capacity = 0;
int was_cancelled = 2;
- c = grpc_channel_create_call(f.client, f.client_cq, "/foo",
+ c = grpc_channel_create_call(f.client, f.cq, "/foo",
"foo.test.google.fr", deadline);
GPR_ASSERT(c);
@@ -145,10 +141,10 @@ static void test_early_server_shutdown_finishes_inflight_calls(
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f.server, &s, &call_details,
- &request_metadata_recv, f.server_cq,
- f.server_cq, tag(101)));
- cq_expect_completion(v_server, tag(101), 1);
- cq_verify(v_server);
+ &request_metadata_recv, f.cq,
+ f.cq, tag(101)));
+ cq_expect_completion(cqv, tag(101), 1);
+ cq_verify(cqv);
op = ops;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
@@ -159,11 +155,9 @@ static void test_early_server_shutdown_finishes_inflight_calls(
/* shutdown and destroy the server */
shutdown_server(&f);
- cq_expect_completion(v_server, tag(102), 1);
- cq_verify(v_server);
-
- cq_expect_completion(v_client, tag(1), 1);
- cq_verify(v_client);
+ cq_expect_completion(cqv, tag(102), 1);
+ cq_expect_completion(cqv, tag(1), 1);
+ cq_verify(cqv);
GPR_ASSERT(status == GRPC_STATUS_UNAVAILABLE);
GPR_ASSERT(0 == strcmp(call_details.method, "/foo"));
@@ -179,8 +173,7 @@ static void test_early_server_shutdown_finishes_inflight_calls(
grpc_call_destroy(c);
grpc_call_destroy(s);
- cq_verifier_destroy(v_client);
- cq_verifier_destroy(v_server);
+ cq_verifier_destroy(cqv);
end_test(&f);
config.tear_down_data(&f);
diff --git a/test/core/end2end/tests/early_server_shutdown_finishes_tags.c b/test/core/end2end/tests/early_server_shutdown_finishes_tags.c
index 857fbb3c88..c52e54b135 100644
--- a/test/core/end2end/tests/early_server_shutdown_finishes_tags.c
+++ b/test/core/end2end/tests/early_server_shutdown_finishes_tags.c
@@ -89,18 +89,15 @@ static void end_test(grpc_end2end_test_fixture *f) {
shutdown_server(f);
shutdown_client(f);
- grpc_completion_queue_shutdown(f->server_cq);
- drain_cq(f->server_cq);
- grpc_completion_queue_destroy(f->server_cq);
- grpc_completion_queue_shutdown(f->client_cq);
- drain_cq(f->client_cq);
- grpc_completion_queue_destroy(f->client_cq);
+ grpc_completion_queue_shutdown(f->cq);
+ drain_cq(f->cq);
+ grpc_completion_queue_destroy(f->cq);
}
static void test_early_server_shutdown_finishes_tags(
grpc_end2end_test_config config) {
grpc_end2end_test_fixture f = begin_test(config, __FUNCTION__, NULL, NULL);
- cq_verifier *v_server = cq_verifier_create(f.server_cq);
+ cq_verifier *cqv = cq_verifier_create(f.cq);
grpc_call *s = (void *)1;
grpc_call_details call_details;
grpc_metadata_array request_metadata_recv;
@@ -112,16 +109,16 @@ static void test_early_server_shutdown_finishes_tags(
no new call */
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f.server, &s, &call_details,
- &request_metadata_recv, f.server_cq,
- f.server_cq, tag(101)));
+ &request_metadata_recv, f.cq,
+ f.cq, tag(101)));
grpc_server_shutdown(f.server);
- cq_expect_completion(v_server, tag(101), 0);
- cq_verify(v_server);
+ cq_expect_completion(cqv, tag(101), 0);
+ cq_verify(cqv);
GPR_ASSERT(s == NULL);
end_test(&f);
config.tear_down_data(&f);
- cq_verifier_destroy(v_server);
+ cq_verifier_destroy(cqv);
}
void grpc_end2end_tests(grpc_end2end_test_config config) {
diff --git a/test/core/end2end/tests/empty_batch.c b/test/core/end2end/tests/empty_batch.c
index a57f921efb..f1c3fb259f 100644
--- a/test/core/end2end/tests/empty_batch.c
+++ b/test/core/end2end/tests/empty_batch.c
@@ -91,31 +91,28 @@ static void end_test(grpc_end2end_test_fixture *f) {
shutdown_server(f);
shutdown_client(f);
- grpc_completion_queue_shutdown(f->server_cq);
- drain_cq(f->server_cq);
- grpc_completion_queue_destroy(f->server_cq);
- grpc_completion_queue_shutdown(f->client_cq);
- drain_cq(f->client_cq);
- grpc_completion_queue_destroy(f->client_cq);
+ grpc_completion_queue_shutdown(f->cq);
+ drain_cq(f->cq);
+ grpc_completion_queue_destroy(f->cq);
}
static void empty_batch_body(grpc_end2end_test_fixture f) {
grpc_call *c;
gpr_timespec deadline = five_seconds_time();
- cq_verifier *v_client = cq_verifier_create(f.client_cq);
+ cq_verifier *cqv = cq_verifier_create(f.cq);
grpc_op *op = NULL;
- c = grpc_channel_create_call(f.client, f.client_cq, "/foo",
+ c = grpc_channel_create_call(f.client, f.cq, "/foo",
"foo.test.google.fr", deadline);
GPR_ASSERT(c);
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(c, op, 0, tag(1)));
- cq_expect_completion(v_client, tag(1), 1);
- cq_verify(v_client);
+ cq_expect_completion(cqv, tag(1), 1);
+ cq_verify(cqv);
grpc_call_destroy(c);
- cq_verifier_destroy(v_client);
+ cq_verifier_destroy(cqv);
}
static void test_invoke_empty_body(grpc_end2end_test_config config) {
diff --git a/test/core/end2end/tests/graceful_server_shutdown.c b/test/core/end2end/tests/graceful_server_shutdown.c
index 9c44f6e127..70a06555fb 100644
--- a/test/core/end2end/tests/graceful_server_shutdown.c
+++ b/test/core/end2end/tests/graceful_server_shutdown.c
@@ -88,12 +88,9 @@ static void end_test(grpc_end2end_test_fixture *f) {
shutdown_server(f);
shutdown_client(f);
- grpc_completion_queue_shutdown(f->server_cq);
- drain_cq(f->server_cq);
- grpc_completion_queue_destroy(f->server_cq);
- grpc_completion_queue_shutdown(f->client_cq);
- drain_cq(f->client_cq);
- grpc_completion_queue_destroy(f->client_cq);
+ grpc_completion_queue_shutdown(f->cq);
+ drain_cq(f->cq);
+ grpc_completion_queue_destroy(f->cq);
}
static void test_early_server_shutdown_finishes_inflight_calls(
@@ -102,8 +99,7 @@ static void test_early_server_shutdown_finishes_inflight_calls(
grpc_call *s;
gpr_timespec deadline = five_seconds_time();
grpc_end2end_test_fixture f = begin_test(config, __FUNCTION__, NULL, NULL);
- cq_verifier *v_client = cq_verifier_create(f.client_cq);
- cq_verifier *v_server = cq_verifier_create(f.server_cq);
+ cq_verifier *cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
grpc_op *op;
grpc_metadata_array initial_metadata_recv;
@@ -115,7 +111,7 @@ static void test_early_server_shutdown_finishes_inflight_calls(
size_t details_capacity = 0;
int was_cancelled = 2;
- c = grpc_channel_create_call(f.client, f.client_cq, "/foo",
+ c = grpc_channel_create_call(f.client, f.cq, "/foo",
"foo.test.google.fr", deadline);
GPR_ASSERT(c);
@@ -144,14 +140,14 @@ static void test_early_server_shutdown_finishes_inflight_calls(
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f.server, &s, &call_details,
- &request_metadata_recv, f.server_cq,
- f.server_cq, tag(101)));
- cq_expect_completion(v_server, tag(101), 1);
- cq_verify(v_server);
+ &request_metadata_recv, f.cq,
+ f.cq, tag(101)));
+ cq_expect_completion(cqv, tag(101), 1);
+ cq_verify(cqv);
/* shutdown and destroy the server */
grpc_server_shutdown_and_notify(f.server, tag(0xdead));
- cq_verify_empty(v_server);
+ cq_verify_empty(cqv);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -167,15 +163,13 @@ static void test_early_server_shutdown_finishes_inflight_calls(
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(s, ops, op - ops, tag(102)));
- cq_expect_completion(v_server, tag(102), 1);
- cq_verify(v_server);
+ cq_expect_completion(cqv, tag(102), 1);
+ cq_verify(cqv);
grpc_call_destroy(s);
- cq_expect_completion(v_server, tag(0xdead), 1);
- cq_verify(v_server);
-
- cq_expect_completion(v_client, tag(1), 1);
- cq_verify(v_client);
+ cq_expect_completion(cqv, tag(0xdead), 1);
+ cq_expect_completion(cqv, tag(1), 1);
+ cq_verify(cqv);
GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED);
GPR_ASSERT(0 == strcmp(call_details.method, "/foo"));
@@ -190,8 +184,7 @@ static void test_early_server_shutdown_finishes_inflight_calls(
grpc_call_destroy(c);
- cq_verifier_destroy(v_client);
- cq_verifier_destroy(v_server);
+ cq_verifier_destroy(cqv);
end_test(&f);
config.tear_down_data(&f);
diff --git a/test/core/end2end/tests/invoke_large_request.c b/test/core/end2end/tests/invoke_large_request.c
index f369e7805e..d4035d0674 100644
--- a/test/core/end2end/tests/invoke_large_request.c
+++ b/test/core/end2end/tests/invoke_large_request.c
@@ -87,12 +87,9 @@ static void end_test(grpc_end2end_test_fixture *f) {
shutdown_server(f);
shutdown_client(f);
- grpc_completion_queue_shutdown(f->server_cq);
- drain_cq(f->server_cq);
- grpc_completion_queue_destroy(f->server_cq);
- grpc_completion_queue_shutdown(f->client_cq);
- drain_cq(f->client_cq);
- grpc_completion_queue_destroy(f->client_cq);
+ grpc_completion_queue_shutdown(f->cq);
+ drain_cq(f->cq);
+ grpc_completion_queue_destroy(f->cq);
}
static gpr_slice large_slice(void) {
@@ -113,8 +110,7 @@ static void test_invoke_large_request(grpc_end2end_test_config config) {
grpc_byte_buffer *response_payload =
grpc_byte_buffer_create(&response_payload_slice, 1);
gpr_timespec deadline = n_seconds_time(30);
- cq_verifier *v_client = cq_verifier_create(f.client_cq);
- cq_verifier *v_server = cq_verifier_create(f.server_cq);
+ cq_verifier *cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
grpc_op *op;
grpc_metadata_array initial_metadata_recv;
@@ -128,7 +124,7 @@ static void test_invoke_large_request(grpc_end2end_test_config config) {
size_t details_capacity = 0;
int was_cancelled = 2;
- c = grpc_channel_create_call(f.client, f.client_cq, "/foo",
+ c = grpc_channel_create_call(f.client, f.cq, "/foo",
"foo.test.google.fr", deadline);
GPR_ASSERT(c);
@@ -162,10 +158,10 @@ static void test_invoke_large_request(grpc_end2end_test_config config) {
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f.server, &s, &call_details,
- &request_metadata_recv, f.server_cq,
- f.server_cq, tag(101)));
- cq_expect_completion(v_server, tag(101), 1);
- cq_verify(v_server);
+ &request_metadata_recv, f.cq,
+ f.cq, tag(101)));
+ cq_expect_completion(cqv, tag(101), 1);
+ cq_verify(cqv);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -187,11 +183,9 @@ static void test_invoke_large_request(grpc_end2end_test_config config) {
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(s, ops, op - ops, tag(102)));
- cq_expect_completion(v_server, tag(102), 1);
- cq_verify(v_server);
-
- cq_expect_completion(v_client, tag(1), 1);
- cq_verify(v_client);
+ cq_expect_completion(cqv, tag(102), 1);
+ cq_expect_completion(cqv, tag(1), 1);
+ cq_verify(cqv);
GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED);
GPR_ASSERT(0 == strcmp(details, "xyz"));
@@ -208,8 +202,7 @@ static void test_invoke_large_request(grpc_end2end_test_config config) {
grpc_call_destroy(c);
grpc_call_destroy(s);
- cq_verifier_destroy(v_client);
- cq_verifier_destroy(v_server);
+ cq_verifier_destroy(cqv);
grpc_byte_buffer_destroy(request_payload);
grpc_byte_buffer_destroy(response_payload);
diff --git a/test/core/end2end/tests/max_concurrent_streams.c b/test/core/end2end/tests/max_concurrent_streams.c
index 59227d98ab..57300a0191 100644
--- a/test/core/end2end/tests/max_concurrent_streams.c
+++ b/test/core/end2end/tests/max_concurrent_streams.c
@@ -89,20 +89,16 @@ static void end_test(grpc_end2end_test_fixture *f) {
shutdown_server(f);
shutdown_client(f);
- grpc_completion_queue_shutdown(f->server_cq);
- drain_cq(f->server_cq);
- grpc_completion_queue_destroy(f->server_cq);
- grpc_completion_queue_shutdown(f->client_cq);
- drain_cq(f->client_cq);
- grpc_completion_queue_destroy(f->client_cq);
+ grpc_completion_queue_shutdown(f->cq);
+ drain_cq(f->cq);
+ grpc_completion_queue_destroy(f->cq);
}
static void simple_request_body(grpc_end2end_test_fixture f) {
grpc_call *c;
grpc_call *s;
gpr_timespec deadline = five_seconds_time();
- cq_verifier *v_client = cq_verifier_create(f.client_cq);
- cq_verifier *v_server = cq_verifier_create(f.server_cq);
+ cq_verifier *cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
grpc_op *op;
grpc_metadata_array initial_metadata_recv;
@@ -114,7 +110,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
size_t details_capacity = 0;
int was_cancelled = 2;
- c = grpc_channel_create_call(f.client, f.client_cq, "/foo",
+ c = grpc_channel_create_call(f.client, f.cq, "/foo",
"foo.test.google.fr:1234", deadline);
GPR_ASSERT(c);
@@ -142,10 +138,10 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f.server, &s, &call_details,
- &request_metadata_recv, f.server_cq,
- f.server_cq, tag(101)));
- cq_expect_completion(v_server, tag(101), 1);
- cq_verify(v_server);
+ &request_metadata_recv, f.cq,
+ f.cq, tag(101)));
+ cq_expect_completion(cqv, tag(101), 1);
+ cq_verify(cqv);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -161,11 +157,9 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(s, ops, op - ops, tag(102)));
- cq_expect_completion(v_server, tag(102), 1);
- cq_verify(v_server);
-
- cq_expect_completion(v_client, tag(1), 1);
- cq_verify(v_client);
+ cq_expect_completion(cqv, tag(102), 1);
+ cq_expect_completion(cqv, tag(1), 1);
+ cq_verify(cqv);
GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED);
GPR_ASSERT(0 == strcmp(details, "xyz"));
@@ -182,8 +176,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
grpc_call_destroy(c);
grpc_call_destroy(s);
- cq_verifier_destroy(v_client);
- cq_verifier_destroy(v_server);
+ cq_verifier_destroy(cqv);
}
static void test_max_concurrent_streams(grpc_end2end_test_config config) {
@@ -196,8 +189,7 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
grpc_call *s2;
int live_call;
gpr_timespec deadline;
- cq_verifier *v_client;
- cq_verifier *v_server;
+ cq_verifier *cqv;
grpc_event ev;
grpc_call_details call_details;
grpc_metadata_array request_metadata_recv;
@@ -214,6 +206,8 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
grpc_op ops[6];
grpc_op *op;
int was_cancelled;
+ int got_client_start;
+ int got_server_start;
server_arg.key = GRPC_ARG_MAX_CONCURRENT_STREAMS;
server_arg.type = GRPC_ARG_INTEGER;
@@ -223,8 +217,7 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
server_args.args = &server_arg;
f = begin_test(config, __FUNCTION__, NULL, &server_args);
- v_client = cq_verifier_create(f.client_cq);
- v_server = cq_verifier_create(f.server_cq);
+ cqv = cq_verifier_create(f.cq);
grpc_metadata_array_init(&request_metadata_recv);
grpc_metadata_array_init(&initial_metadata_recv1);
@@ -241,18 +234,18 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
/* start two requests - ensuring that the second is not accepted until
the first completes */
- deadline = n_seconds_time(10);
- c1 = grpc_channel_create_call(f.client, f.client_cq, "/alpha",
+ deadline = n_seconds_time(1000);
+ c1 = grpc_channel_create_call(f.client, f.cq, "/alpha",
"foo.test.google.fr:1234", deadline);
GPR_ASSERT(c1);
- c2 = grpc_channel_create_call(f.client, f.client_cq, "/beta",
+ c2 = grpc_channel_create_call(f.client, f.cq, "/beta",
"foo.test.google.fr:1234", deadline);
GPR_ASSERT(c2);
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f.server, &s1, &call_details,
- &request_metadata_recv, f.server_cq,
- f.server_cq, tag(101)));
+ &request_metadata_recv, f.cq,
+ f.cq, tag(101)));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -298,18 +291,28 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
GPR_ASSERT(GRPC_CALL_OK ==
grpc_call_start_batch(c2, ops, op - ops, tag(402)));
- cq_expect_completion(v_server, tag(101), 1);
- cq_verify(v_server);
-
- ev = grpc_completion_queue_next(f.client_cq,
- GRPC_TIMEOUT_SECONDS_TO_DEADLINE(3));
- GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
- GPR_ASSERT(ev.success);
- GPR_ASSERT(ev.tag == tag(301) || ev.tag == tag(401));
- /* The /alpha or /beta calls started above could be invoked (but NOT both);
- * check this here */
- /* We'll get tag 303 or 403, we want 300, 400 */
- live_call = ((int)(gpr_intptr)ev.tag) - 1;
+ got_client_start = 0;
+ got_server_start = 0;
+ live_call = -1;
+ while (!got_client_start || !got_server_start) {
+ ev = grpc_completion_queue_next(f.cq,
+ GRPC_TIMEOUT_SECONDS_TO_DEADLINE(3));
+ GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
+ GPR_ASSERT(ev.success);
+ if (ev.tag == tag(101)) {
+ GPR_ASSERT(!got_server_start);
+ got_server_start = 1;
+ } else {
+ GPR_ASSERT(!got_client_start);
+ GPR_ASSERT(ev.tag == tag(301) || ev.tag == tag(401));
+ /* The /alpha or /beta calls started above could be invoked (but NOT both);
+ * check this here */
+ /* We'll get tag 303 or 403, we want 300, 400 */
+ live_call = ((int)(gpr_intptr)ev.tag) - 1;
+ got_client_start = 1;
+ }
+ }
+ GPR_ASSERT(live_call == 300 || live_call == 400);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -326,21 +329,19 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
GPR_ASSERT(GRPC_CALL_OK ==
grpc_call_start_batch(s1, ops, op - ops, tag(102)));
- cq_expect_completion(v_server, tag(102), 1);
- cq_verify(v_server);
-
- cq_expect_completion(v_client, tag(live_call + 2), 1);
+ cq_expect_completion(cqv, tag(102), 1);
+ cq_expect_completion(cqv, tag(live_call + 2), 1);
/* first request is finished, we should be able to start the second */
live_call = (live_call == 300) ? 400 : 300;
- cq_expect_completion(v_client, tag(live_call + 1), 1);
- cq_verify(v_client);
+ cq_expect_completion(cqv, tag(live_call + 1), 1);
+ cq_verify(cqv);
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f.server, &s2, &call_details,
- &request_metadata_recv, f.server_cq,
- f.server_cq, tag(201)));
- cq_expect_completion(v_server, tag(201), 1);
- cq_verify(v_server);
+ &request_metadata_recv, f.cq,
+ f.cq, tag(201)));
+ cq_expect_completion(cqv, tag(201), 1);
+ cq_verify(cqv);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -357,14 +358,11 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
GPR_ASSERT(GRPC_CALL_OK ==
grpc_call_start_batch(s2, ops, op - ops, tag(202)));
- cq_expect_completion(v_client, tag(live_call + 2), 1);
- cq_verify(v_client);
-
- cq_expect_completion(v_server, tag(202), 1);
- cq_verify(v_server);
+ cq_expect_completion(cqv, tag(live_call + 2), 1);
+ cq_expect_completion(cqv, tag(202), 1);
+ cq_verify(cqv);
- cq_verifier_destroy(v_client);
- cq_verifier_destroy(v_server);
+ cq_verifier_destroy(cqv);
grpc_call_destroy(c1);
grpc_call_destroy(s1);
diff --git a/test/core/end2end/tests/max_message_length.c b/test/core/end2end/tests/max_message_length.c
index 99aeb9d049..364d59eea3 100644
--- a/test/core/end2end/tests/max_message_length.c
+++ b/test/core/end2end/tests/max_message_length.c
@@ -89,12 +89,9 @@ static void end_test(grpc_end2end_test_fixture *f) {
shutdown_server(f);
shutdown_client(f);
- grpc_completion_queue_shutdown(f->server_cq);
- drain_cq(f->server_cq);
- grpc_completion_queue_destroy(f->server_cq);
- grpc_completion_queue_shutdown(f->client_cq);
- drain_cq(f->client_cq);
- grpc_completion_queue_destroy(f->client_cq);
+ grpc_completion_queue_shutdown(f->cq);
+ drain_cq(f->cq);
+ grpc_completion_queue_destroy(f->cq);
}
static void test_max_message_length(grpc_end2end_test_config config) {
@@ -103,8 +100,7 @@ static void test_max_message_length(grpc_end2end_test_config config) {
grpc_channel_args server_args;
grpc_call *c;
grpc_call *s;
- cq_verifier *v_client;
- cq_verifier *v_server;
+ cq_verifier *cqv;
grpc_op ops[6];
grpc_op *op;
gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world");
@@ -127,10 +123,9 @@ static void test_max_message_length(grpc_end2end_test_config config) {
server_args.args = &server_arg;
f = begin_test(config, __FUNCTION__, NULL, &server_args);
- v_client = cq_verifier_create(f.client_cq);
- v_server = cq_verifier_create(f.server_cq);
+ cqv = cq_verifier_create(f.cq);
- c = grpc_channel_create_call(f.client, f.client_cq, "/foo",
+ c = grpc_channel_create_call(f.client, f.cq, "/foo",
"foo.test.google.fr:1234", gpr_inf_future);
GPR_ASSERT(c);
@@ -161,10 +156,10 @@ static void test_max_message_length(grpc_end2end_test_config config) {
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f.server, &s, &call_details,
- &request_metadata_recv, f.server_cq,
- f.server_cq, tag(101)));
- cq_expect_completion(v_server, tag(101), 1);
- cq_verify(v_server);
+ &request_metadata_recv, f.cq,
+ f.cq, tag(101)));
+ cq_expect_completion(cqv, tag(101), 1);
+ cq_verify(cqv);
op = ops;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
@@ -172,11 +167,9 @@ static void test_max_message_length(grpc_end2end_test_config config) {
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(s, ops, op - ops, tag(102)));
- cq_expect_completion(v_server, tag(102), 1);
- cq_verify(v_server);
-
- cq_expect_completion(v_client, tag(1), 1);
- cq_verify(v_client);
+ cq_expect_completion(cqv, tag(102), 1);
+ cq_expect_completion(cqv, tag(1), 1);
+ cq_verify(cqv);
GPR_ASSERT(status == GRPC_STATUS_CANCELLED);
GPR_ASSERT(0 == strcmp(details, "Cancelled"));
@@ -193,8 +186,7 @@ static void test_max_message_length(grpc_end2end_test_config config) {
grpc_call_destroy(c);
grpc_call_destroy(s);
- cq_verifier_destroy(v_client);
- cq_verifier_destroy(v_server);
+ cq_verifier_destroy(cqv);
end_test(&f);
config.tear_down_data(&f);
diff --git a/test/core/end2end/tests/no_op.c b/test/core/end2end/tests/no_op.c
index 000d2ffa2a..979eb06d6c 100644
--- a/test/core/end2end/tests/no_op.c
+++ b/test/core/end2end/tests/no_op.c
@@ -87,12 +87,9 @@ static void end_test(grpc_end2end_test_fixture *f) {
shutdown_server(f);
shutdown_client(f);
- grpc_completion_queue_shutdown(f->server_cq);
- drain_cq(f->server_cq);
- grpc_completion_queue_destroy(f->server_cq);
- grpc_completion_queue_shutdown(f->client_cq);
- drain_cq(f->client_cq);
- grpc_completion_queue_destroy(f->client_cq);
+ grpc_completion_queue_shutdown(f->cq);
+ drain_cq(f->cq);
+ grpc_completion_queue_destroy(f->cq);
}
static void test_no_op(grpc_end2end_test_config config) {
diff --git a/test/core/end2end/tests/ping_pong_streaming.c b/test/core/end2end/tests/ping_pong_streaming.c
index 2bd17924f3..c00beb7770 100644
--- a/test/core/end2end/tests/ping_pong_streaming.c
+++ b/test/core/end2end/tests/ping_pong_streaming.c
@@ -89,12 +89,9 @@ static void end_test(grpc_end2end_test_fixture *f) {
shutdown_server(f);
shutdown_client(f);
- grpc_completion_queue_shutdown(f->server_cq);
- drain_cq(f->server_cq);
- grpc_completion_queue_destroy(f->server_cq);
- grpc_completion_queue_shutdown(f->client_cq);
- drain_cq(f->client_cq);
- grpc_completion_queue_destroy(f->client_cq);
+ grpc_completion_queue_shutdown(f->cq);
+ drain_cq(f->cq);
+ grpc_completion_queue_destroy(f->cq);
}
/* Client pings and server pongs. Repeat messages rounds before finishing. */
@@ -104,8 +101,7 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
grpc_call *c;
grpc_call *s;
gpr_timespec deadline = five_seconds_time();
- cq_verifier *v_client = cq_verifier_create(f.client_cq);
- cq_verifier *v_server = cq_verifier_create(f.server_cq);
+ cq_verifier *cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
grpc_op *op;
grpc_metadata_array initial_metadata_recv;
@@ -124,7 +120,7 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world");
gpr_slice response_payload_slice = gpr_slice_from_copied_string("hello you");
- c = grpc_channel_create_call(f.client, f.client_cq, "/foo",
+ c = grpc_channel_create_call(f.client, f.cq, "/foo",
"foo.test.google.fr:1234", deadline);
GPR_ASSERT(c);
@@ -150,10 +146,10 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f.server, &s, &call_details,
- &request_metadata_recv, f.server_cq,
- f.server_cq, tag(100)));
- cq_expect_completion(v_server, tag(100), 1);
- cq_verify(v_server);
+ &request_metadata_recv, f.cq,
+ f.cq, tag(100)));
+ cq_expect_completion(cqv, tag(100), 1);
+ cq_verify(cqv);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -183,8 +179,8 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
op++;
GPR_ASSERT(GRPC_CALL_OK ==
grpc_call_start_batch(s, ops, op - ops, tag(102)));
- cq_expect_completion(v_server, tag(102), 1);
- cq_verify(v_server);
+ cq_expect_completion(cqv, tag(102), 1);
+ cq_verify(cqv);
op = ops;
op->op = GRPC_OP_SEND_MESSAGE;
@@ -192,11 +188,9 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
op++;
GPR_ASSERT(GRPC_CALL_OK ==
grpc_call_start_batch(s, ops, op - ops, tag(103)));
- cq_expect_completion(v_server, tag(103), 1);
- cq_verify(v_server);
-
- cq_expect_completion(v_client, tag(2), 1);
- cq_verify(v_client);
+ cq_expect_completion(cqv, tag(103), 1);
+ cq_expect_completion(cqv, tag(2), 1);
+ cq_verify(cqv);
grpc_byte_buffer_destroy(request_payload);
grpc_byte_buffer_destroy(response_payload);
@@ -220,19 +214,16 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(s, ops, op - ops, tag(104)));
- cq_expect_completion(v_client, tag(1), 1);
- cq_expect_completion(v_client, tag(3), 1);
- cq_verify(v_client);
-
- cq_expect_completion(v_server, tag(101), 1);
- cq_expect_completion(v_server, tag(104), 1);
- cq_verify(v_server);
+ cq_expect_completion(cqv, tag(1), 1);
+ cq_expect_completion(cqv, tag(3), 1);
+ cq_expect_completion(cqv, tag(101), 1);
+ cq_expect_completion(cqv, tag(104), 1);
+ cq_verify(cqv);
grpc_call_destroy(c);
grpc_call_destroy(s);
- cq_verifier_destroy(v_client);
- cq_verifier_destroy(v_server);
+ cq_verifier_destroy(cqv);
grpc_metadata_array_destroy(&initial_metadata_recv);
grpc_metadata_array_destroy(&trailing_metadata_recv);
diff --git a/test/core/end2end/tests/registered_call.c b/test/core/end2end/tests/registered_call.c
index 54663c3690..80f7d20dce 100644
--- a/test/core/end2end/tests/registered_call.c
+++ b/test/core/end2end/tests/registered_call.c
@@ -91,20 +91,16 @@ static void end_test(grpc_end2end_test_fixture *f) {
shutdown_server(f);
shutdown_client(f);
- grpc_completion_queue_shutdown(f->server_cq);
- drain_cq(f->server_cq);
- grpc_completion_queue_destroy(f->server_cq);
- grpc_completion_queue_shutdown(f->client_cq);
- drain_cq(f->client_cq);
- grpc_completion_queue_destroy(f->client_cq);
+ grpc_completion_queue_shutdown(f->cq);
+ drain_cq(f->cq);
+ grpc_completion_queue_destroy(f->cq);
}
static void simple_request_body(grpc_end2end_test_fixture f, void *rc) {
grpc_call *c;
grpc_call *s;
gpr_timespec deadline = five_seconds_time();
- cq_verifier *v_client = cq_verifier_create(f.client_cq);
- cq_verifier *v_server = cq_verifier_create(f.server_cq);
+ cq_verifier *cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
grpc_op *op;
grpc_metadata_array initial_metadata_recv;
@@ -116,7 +112,7 @@ static void simple_request_body(grpc_end2end_test_fixture f, void *rc) {
size_t details_capacity = 0;
int was_cancelled = 2;
- c = grpc_channel_create_registered_call(f.client, f.client_cq, rc, deadline);
+ c = grpc_channel_create_registered_call(f.client, f.cq, rc, deadline);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@@ -143,10 +139,10 @@ static void simple_request_body(grpc_end2end_test_fixture f, void *rc) {
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f.server, &s, &call_details,
- &request_metadata_recv, f.server_cq,
- f.server_cq, tag(101)));
- cq_expect_completion(v_server, tag(101), 1);
- cq_verify(v_server);
+ &request_metadata_recv, f.cq,
+ f.cq, tag(101)));
+ cq_expect_completion(cqv, tag(101), 1);
+ cq_verify(cqv);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -162,11 +158,9 @@ static void simple_request_body(grpc_end2end_test_fixture f, void *rc) {
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(s, ops, op - ops, tag(102)));
- cq_expect_completion(v_server, tag(102), 1);
- cq_verify(v_server);
-
- cq_expect_completion(v_client, tag(1), 1);
- cq_verify(v_client);
+ cq_expect_completion(cqv, tag(102), 1);
+ cq_expect_completion(cqv, tag(1), 1);
+ cq_verify(cqv);
GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED);
GPR_ASSERT(0 == strcmp(details, "xyz"));
@@ -183,8 +177,7 @@ static void simple_request_body(grpc_end2end_test_fixture f, void *rc) {
grpc_call_destroy(c);
grpc_call_destroy(s);
- cq_verifier_destroy(v_client);
- cq_verifier_destroy(v_server);
+ cq_verifier_destroy(cqv);
}
static void test_invoke_simple_request(grpc_end2end_test_config config) {
diff --git a/test/core/end2end/tests/request_response_with_binary_metadata_and_payload.c b/test/core/end2end/tests/request_response_with_binary_metadata_and_payload.c
index 709dc47b72..ce872a4082 100644
--- a/test/core/end2end/tests/request_response_with_binary_metadata_and_payload.c
+++ b/test/core/end2end/tests/request_response_with_binary_metadata_and_payload.c
@@ -89,12 +89,9 @@ static void end_test(grpc_end2end_test_fixture *f) {
shutdown_server(f);
shutdown_client(f);
- grpc_completion_queue_shutdown(f->server_cq);
- drain_cq(f->server_cq);
- grpc_completion_queue_destroy(f->server_cq);
- grpc_completion_queue_shutdown(f->client_cq);
- drain_cq(f->client_cq);
- grpc_completion_queue_destroy(f->client_cq);
+ grpc_completion_queue_shutdown(f->cq);
+ drain_cq(f->cq);
+ grpc_completion_queue_destroy(f->cq);
}
/* Request/response with metadata and payload.*/
@@ -128,8 +125,7 @@ static void test_request_response_with_metadata_and_payload(
16,
{{NULL, NULL, NULL}}}};
grpc_end2end_test_fixture f = begin_test(config, __FUNCTION__, NULL, NULL);
- cq_verifier *v_client = cq_verifier_create(f.client_cq);
- cq_verifier *v_server = cq_verifier_create(f.server_cq);
+ cq_verifier *cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
grpc_op *op;
grpc_metadata_array initial_metadata_recv;
@@ -143,7 +139,7 @@ static void test_request_response_with_metadata_and_payload(
size_t details_capacity = 0;
int was_cancelled = 2;
- c = grpc_channel_create_call(f.client, f.client_cq, "/foo",
+ c = grpc_channel_create_call(f.client, f.cq, "/foo",
"foo.test.google.fr", deadline);
GPR_ASSERT(c);
@@ -178,10 +174,10 @@ static void test_request_response_with_metadata_and_payload(
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f.server, &s, &call_details,
- &request_metadata_recv, f.server_cq,
- f.server_cq, tag(101)));
- cq_expect_completion(v_server, tag(101), 1);
- cq_verify(v_server);
+ &request_metadata_recv, f.cq,
+ f.cq, tag(101)));
+ cq_expect_completion(cqv, tag(101), 1);
+ cq_verify(cqv);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -204,11 +200,9 @@ static void test_request_response_with_metadata_and_payload(
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(s, ops, op - ops, tag(102)));
- cq_expect_completion(v_server, tag(102), 1);
- cq_verify(v_server);
-
- cq_expect_completion(v_client, tag(1), 1);
- cq_verify(v_client);
+ cq_expect_completion(cqv, tag(102), 1);
+ cq_expect_completion(cqv, tag(1), 1);
+ cq_verify(cqv);
GPR_ASSERT(status == GRPC_STATUS_OK);
GPR_ASSERT(0 == strcmp(details, "xyz"));
@@ -239,8 +233,7 @@ static void test_request_response_with_metadata_and_payload(
grpc_call_destroy(c);
grpc_call_destroy(s);
- cq_verifier_destroy(v_client);
- cq_verifier_destroy(v_server);
+ cq_verifier_destroy(cqv);
grpc_byte_buffer_destroy(request_payload);
grpc_byte_buffer_destroy(response_payload);
diff --git a/test/core/end2end/tests/request_response_with_metadata_and_payload.c b/test/core/end2end/tests/request_response_with_metadata_and_payload.c
index bc32a503dd..b4edb7362d 100644
--- a/test/core/end2end/tests/request_response_with_metadata_and_payload.c
+++ b/test/core/end2end/tests/request_response_with_metadata_and_payload.c
@@ -89,12 +89,9 @@ static void end_test(grpc_end2end_test_fixture *f) {
shutdown_server(f);
shutdown_client(f);
- grpc_completion_queue_shutdown(f->server_cq);
- drain_cq(f->server_cq);
- grpc_completion_queue_destroy(f->server_cq);
- grpc_completion_queue_shutdown(f->client_cq);
- drain_cq(f->client_cq);
- grpc_completion_queue_destroy(f->client_cq);
+ grpc_completion_queue_shutdown(f->cq);
+ drain_cq(f->cq);
+ grpc_completion_queue_destroy(f->cq);
}
/* Request/response with metadata and payload.*/
@@ -114,8 +111,7 @@ static void test_request_response_with_metadata_and_payload(
grpc_metadata meta_s[2] = {{"key3", "val3", 4, {{NULL, NULL, NULL}}},
{"key4", "val4", 4, {{NULL, NULL, NULL}}}};
grpc_end2end_test_fixture f = begin_test(config, __FUNCTION__, NULL, NULL);
- cq_verifier *v_client = cq_verifier_create(f.client_cq);
- cq_verifier *v_server = cq_verifier_create(f.server_cq);
+ cq_verifier *cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
grpc_op *op;
grpc_metadata_array initial_metadata_recv;
@@ -129,7 +125,7 @@ static void test_request_response_with_metadata_and_payload(
size_t details_capacity = 0;
int was_cancelled = 2;
- c = grpc_channel_create_call(f.client, f.client_cq, "/foo",
+ c = grpc_channel_create_call(f.client, f.cq, "/foo",
"foo.test.google.fr", deadline);
GPR_ASSERT(c);
@@ -164,10 +160,10 @@ static void test_request_response_with_metadata_and_payload(
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f.server, &s, &call_details,
- &request_metadata_recv, f.server_cq,
- f.server_cq, tag(101)));
- cq_expect_completion(v_server, tag(101), 1);
- cq_verify(v_server);
+ &request_metadata_recv, f.cq,
+ f.cq, tag(101)));
+ cq_expect_completion(cqv, tag(101), 1);
+ cq_verify(cqv);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -190,11 +186,9 @@ static void test_request_response_with_metadata_and_payload(
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(s, ops, op - ops, tag(102)));
- cq_expect_completion(v_server, tag(102), 1);
- cq_verify(v_server);
-
- cq_expect_completion(v_client, tag(1), 1);
- cq_verify(v_client);
+ cq_expect_completion(cqv, tag(102), 1);
+ cq_expect_completion(cqv, tag(1), 1);
+ cq_verify(cqv);
GPR_ASSERT(status == GRPC_STATUS_OK);
GPR_ASSERT(0 == strcmp(details, "xyz"));
@@ -217,8 +211,7 @@ static void test_request_response_with_metadata_and_payload(
grpc_call_destroy(c);
grpc_call_destroy(s);
- cq_verifier_destroy(v_client);
- cq_verifier_destroy(v_server);
+ cq_verifier_destroy(cqv);
grpc_byte_buffer_destroy(request_payload);
grpc_byte_buffer_destroy(response_payload);
diff --git a/test/core/end2end/tests/request_response_with_payload.c b/test/core/end2end/tests/request_response_with_payload.c
index be0cca696b..cb50855561 100644
--- a/test/core/end2end/tests/request_response_with_payload.c
+++ b/test/core/end2end/tests/request_response_with_payload.c
@@ -89,12 +89,9 @@ static void end_test(grpc_end2end_test_fixture *f) {
shutdown_server(f);
shutdown_client(f);
- grpc_completion_queue_shutdown(f->server_cq);
- drain_cq(f->server_cq);
- grpc_completion_queue_destroy(f->server_cq);
- grpc_completion_queue_shutdown(f->client_cq);
- drain_cq(f->client_cq);
- grpc_completion_queue_destroy(f->client_cq);
+ grpc_completion_queue_shutdown(f->cq);
+ drain_cq(f->cq);
+ grpc_completion_queue_destroy(f->cq);
}
static void request_response_with_payload(grpc_end2end_test_fixture f) {
@@ -107,8 +104,7 @@ static void request_response_with_payload(grpc_end2end_test_fixture f) {
grpc_byte_buffer *response_payload =
grpc_byte_buffer_create(&response_payload_slice, 1);
gpr_timespec deadline = five_seconds_time();
- cq_verifier *v_client = cq_verifier_create(f.client_cq);
- cq_verifier *v_server = cq_verifier_create(f.server_cq);
+ cq_verifier *cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
grpc_op *op;
grpc_metadata_array initial_metadata_recv;
@@ -122,7 +118,7 @@ static void request_response_with_payload(grpc_end2end_test_fixture f) {
size_t details_capacity = 0;
int was_cancelled = 2;
- c = grpc_channel_create_call(f.client, f.client_cq, "/foo",
+ c = grpc_channel_create_call(f.client, f.cq, "/foo",
"foo.test.google.fr", deadline);
GPR_ASSERT(c);
@@ -156,10 +152,10 @@ static void request_response_with_payload(grpc_end2end_test_fixture f) {
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f.server, &s, &call_details,
- &request_metadata_recv, f.server_cq,
- f.server_cq, tag(101)));
- cq_expect_completion(v_server, tag(101), 1);
- cq_verify(v_server);
+ &request_metadata_recv, f.cq,
+ f.cq, tag(101)));
+ cq_expect_completion(cqv, tag(101), 1);
+ cq_verify(cqv);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -181,11 +177,9 @@ static void request_response_with_payload(grpc_end2end_test_fixture f) {
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(s, ops, op - ops, tag(102)));
- cq_expect_completion(v_server, tag(102), 1);
- cq_verify(v_server);
-
- cq_expect_completion(v_client, tag(1), 1);
- cq_verify(v_client);
+ cq_expect_completion(cqv, tag(102), 1);
+ cq_expect_completion(cqv, tag(1), 1);
+ cq_verify(cqv);
GPR_ASSERT(status == GRPC_STATUS_OK);
GPR_ASSERT(0 == strcmp(details, "xyz"));
@@ -204,8 +198,7 @@ static void request_response_with_payload(grpc_end2end_test_fixture f) {
grpc_call_destroy(c);
grpc_call_destroy(s);
- cq_verifier_destroy(v_client);
- cq_verifier_destroy(v_server);
+ cq_verifier_destroy(cqv);
grpc_byte_buffer_destroy(request_payload);
grpc_byte_buffer_destroy(response_payload);
diff --git a/test/core/end2end/tests/request_response_with_payload_and_call_creds.c b/test/core/end2end/tests/request_response_with_payload_and_call_creds.c
index 01554bed8c..f9371f6df9 100644
--- a/test/core/end2end/tests/request_response_with_payload_and_call_creds.c
+++ b/test/core/end2end/tests/request_response_with_payload_and_call_creds.c
@@ -103,12 +103,9 @@ static void end_test(grpc_end2end_test_fixture *f) {
shutdown_server(f);
shutdown_client(f);
- grpc_completion_queue_shutdown(f->server_cq);
- drain_cq(f->server_cq);
- grpc_completion_queue_destroy(f->server_cq);
- grpc_completion_queue_shutdown(f->client_cq);
- drain_cq(f->client_cq);
- grpc_completion_queue_destroy(f->client_cq);
+ grpc_completion_queue_shutdown(f->cq);
+ drain_cq(f->cq);
+ grpc_completion_queue_destroy(f->cq);
}
static void test_call_creds_failure(grpc_end2end_test_config config) {
@@ -116,7 +113,7 @@ static void test_call_creds_failure(grpc_end2end_test_config config) {
grpc_credentials *creds = NULL;
grpc_end2end_test_fixture f = begin_test(config, __FUNCTION__, NULL, NULL);
gpr_timespec deadline = five_seconds_time();
- c = grpc_channel_create_call(f.client, f.client_cq, "/foo",
+ c = grpc_channel_create_call(f.client, f.cq, "/foo",
"foo.test.google.fr", deadline);
GPR_ASSERT(c);
@@ -143,8 +140,7 @@ static void request_response_with_payload_and_call_creds(
gpr_timespec deadline = five_seconds_time();
grpc_end2end_test_fixture f = begin_test(config, test_name, NULL, NULL);
- cq_verifier *v_client = cq_verifier_create(f.client_cq);
- cq_verifier *v_server = cq_verifier_create(f.server_cq);
+ cq_verifier *cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
grpc_op *op;
grpc_metadata_array initial_metadata_recv;
@@ -159,7 +155,7 @@ static void request_response_with_payload_and_call_creds(
int was_cancelled = 2;
grpc_credentials *creds = NULL;
- c = grpc_channel_create_call(f.client, f.client_cq, "/foo",
+ c = grpc_channel_create_call(f.client, f.cq, "/foo",
"foo.test.google.fr", deadline);
GPR_ASSERT(c);
creds = grpc_iam_credentials_create(iam_token, iam_selector);
@@ -212,10 +208,10 @@ static void request_response_with_payload_and_call_creds(
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(f.server, &s,
&call_details,
&request_metadata_recv,
- f.server_cq, f.server_cq,
+ f.cq, f.cq,
tag(101)));
- cq_expect_completion(v_server, tag(101), 1);
- cq_verify(v_server);
+ cq_expect_completion(cqv, tag(101), 1);
+ cq_verify(cqv);
/* Cannot set creds on the server call object. */
GPR_ASSERT(grpc_call_set_credentials(s, NULL) != GRPC_CALL_OK);
@@ -240,11 +236,9 @@ static void request_response_with_payload_and_call_creds(
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(s, ops, op - ops, tag(102)));
- cq_expect_completion(v_server, tag(102), 1);
- cq_verify(v_server);
-
- cq_expect_completion(v_client, tag(1), 1);
- cq_verify(v_client);
+ cq_expect_completion(cqv, tag(102), 1);
+ cq_expect_completion(cqv, tag(1), 1);
+ cq_verify(cqv);
GPR_ASSERT(status == GRPC_STATUS_OK);
GPR_ASSERT(0 == strcmp(details, "xyz"));
@@ -296,8 +290,7 @@ static void request_response_with_payload_and_call_creds(
grpc_call_destroy(c);
grpc_call_destroy(s);
- cq_verifier_destroy(v_client);
- cq_verifier_destroy(v_server);
+ cq_verifier_destroy(cqv);
grpc_byte_buffer_destroy(request_payload);
grpc_byte_buffer_destroy(response_payload);
diff --git a/test/core/end2end/tests/request_with_large_metadata.c b/test/core/end2end/tests/request_with_large_metadata.c
index 08a16213a1..a137786d50 100644
--- a/test/core/end2end/tests/request_with_large_metadata.c
+++ b/test/core/end2end/tests/request_with_large_metadata.c
@@ -89,12 +89,9 @@ static void end_test(grpc_end2end_test_fixture *f) {
shutdown_server(f);
shutdown_client(f);
- grpc_completion_queue_shutdown(f->server_cq);
- drain_cq(f->server_cq);
- grpc_completion_queue_destroy(f->server_cq);
- grpc_completion_queue_shutdown(f->client_cq);
- drain_cq(f->client_cq);
- grpc_completion_queue_destroy(f->client_cq);
+ grpc_completion_queue_shutdown(f->cq);
+ drain_cq(f->cq);
+ grpc_completion_queue_destroy(f->cq);
}
/* Request with a large amount of metadata.*/
@@ -107,8 +104,7 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) {
gpr_timespec deadline = five_seconds_time();
grpc_metadata meta;
grpc_end2end_test_fixture f = begin_test(config, __FUNCTION__, NULL, NULL);
- cq_verifier *v_client = cq_verifier_create(f.client_cq);
- cq_verifier *v_server = cq_verifier_create(f.server_cq);
+ cq_verifier *cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
grpc_op *op;
grpc_metadata_array initial_metadata_recv;
@@ -122,7 +118,7 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) {
int was_cancelled = 2;
const int large_size = 64 * 1024;
- c = grpc_channel_create_call(f.client, f.client_cq, "/foo",
+ c = grpc_channel_create_call(f.client, f.cq, "/foo",
"foo.test.google.fr", deadline);
GPR_ASSERT(c);
@@ -160,10 +156,10 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) {
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f.server, &s, &call_details,
- &request_metadata_recv, f.server_cq,
- f.server_cq, tag(101)));
- cq_expect_completion(v_server, tag(101), 1);
- cq_verify(v_server);
+ &request_metadata_recv, f.cq,
+ f.cq, tag(101)));
+ cq_expect_completion(cqv, tag(101), 1);
+ cq_verify(cqv);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -182,11 +178,9 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) {
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(s, ops, op - ops, tag(102)));
- cq_expect_completion(v_server, tag(102), 1);
- cq_verify(v_server);
-
- cq_expect_completion(v_client, tag(1), 1);
- cq_verify(v_client);
+ cq_expect_completion(cqv, tag(102), 1);
+ cq_expect_completion(cqv, tag(1), 1);
+ cq_verify(cqv);
GPR_ASSERT(status == GRPC_STATUS_OK);
GPR_ASSERT(0 == strcmp(details, "xyz"));
@@ -205,8 +199,7 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) {
grpc_call_destroy(c);
grpc_call_destroy(s);
- cq_verifier_destroy(v_client);
- cq_verifier_destroy(v_server);
+ cq_verifier_destroy(cqv);
grpc_byte_buffer_destroy(request_payload);
grpc_byte_buffer_destroy(request_payload_recv);
diff --git a/test/core/end2end/tests/request_with_payload.c b/test/core/end2end/tests/request_with_payload.c
index bba50b3113..86199c9f43 100644
--- a/test/core/end2end/tests/request_with_payload.c
+++ b/test/core/end2end/tests/request_with_payload.c
@@ -89,12 +89,9 @@ static void end_test(grpc_end2end_test_fixture *f) {
shutdown_server(f);
shutdown_client(f);
- grpc_completion_queue_shutdown(f->server_cq);
- drain_cq(f->server_cq);
- grpc_completion_queue_destroy(f->server_cq);
- grpc_completion_queue_shutdown(f->client_cq);
- drain_cq(f->client_cq);
- grpc_completion_queue_destroy(f->client_cq);
+ grpc_completion_queue_shutdown(f->cq);
+ drain_cq(f->cq);
+ grpc_completion_queue_destroy(f->cq);
}
/* Client sends a request with payload, server reads then returns status. */
@@ -106,8 +103,7 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
grpc_byte_buffer_create(&request_payload_slice, 1);
gpr_timespec deadline = five_seconds_time();
grpc_end2end_test_fixture f = begin_test(config, __FUNCTION__, NULL, NULL);
- cq_verifier *v_client = cq_verifier_create(f.client_cq);
- cq_verifier *v_server = cq_verifier_create(f.server_cq);
+ cq_verifier *cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
grpc_op *op;
grpc_metadata_array initial_metadata_recv;
@@ -120,7 +116,7 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
size_t details_capacity = 0;
int was_cancelled = 2;
- c = grpc_channel_create_call(f.client, f.client_cq, "/foo",
+ c = grpc_channel_create_call(f.client, f.cq, "/foo",
"foo.test.google.fr", deadline);
GPR_ASSERT(c);
@@ -151,10 +147,10 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f.server, &s, &call_details,
- &request_metadata_recv, f.server_cq,
- f.server_cq, tag(101)));
- cq_expect_completion(v_server, tag(101), 1);
- cq_verify(v_server);
+ &request_metadata_recv, f.cq,
+ f.cq, tag(101)));
+ cq_expect_completion(cqv, tag(101), 1);
+ cq_verify(cqv);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -173,11 +169,9 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(s, ops, op - ops, tag(102)));
- cq_expect_completion(v_server, tag(102), 1);
- cq_verify(v_server);
-
- cq_expect_completion(v_client, tag(1), 1);
- cq_verify(v_client);
+ cq_expect_completion(cqv, tag(102), 1);
+ cq_expect_completion(cqv, tag(1), 1);
+ cq_verify(cqv);
GPR_ASSERT(status == GRPC_STATUS_OK);
GPR_ASSERT(0 == strcmp(details, "xyz"));
@@ -195,8 +189,7 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
grpc_call_destroy(c);
grpc_call_destroy(s);
- cq_verifier_destroy(v_client);
- cq_verifier_destroy(v_server);
+ cq_verifier_destroy(cqv);
grpc_byte_buffer_destroy(request_payload);
grpc_byte_buffer_destroy(request_payload_recv);
diff --git a/test/core/end2end/tests/simple_delayed_request.c b/test/core/end2end/tests/simple_delayed_request.c
index d8463d4c6c..c51019caff 100644
--- a/test/core/end2end/tests/simple_delayed_request.c
+++ b/test/core/end2end/tests/simple_delayed_request.c
@@ -77,12 +77,9 @@ static void end_test(grpc_end2end_test_fixture *f) {
shutdown_server(f);
shutdown_client(f);
- grpc_completion_queue_shutdown(f->server_cq);
- drain_cq(f->server_cq);
- grpc_completion_queue_destroy(f->server_cq);
- grpc_completion_queue_shutdown(f->client_cq);
- drain_cq(f->client_cq);
- grpc_completion_queue_destroy(f->client_cq);
+ grpc_completion_queue_shutdown(f->cq);
+ drain_cq(f->cq);
+ grpc_completion_queue_destroy(f->cq);
}
static void simple_delayed_request_body(grpc_end2end_test_config config,
@@ -93,8 +90,7 @@ static void simple_delayed_request_body(grpc_end2end_test_config config,
grpc_call *c;
grpc_call *s;
gpr_timespec deadline = five_seconds_time();
- cq_verifier *v_client = cq_verifier_create(f->client_cq);
- cq_verifier *v_server = cq_verifier_create(f->server_cq);
+ cq_verifier *cqv = cq_verifier_create(f->cq);
grpc_op ops[6];
grpc_op *op;
grpc_metadata_array initial_metadata_recv;
@@ -108,7 +104,7 @@ static void simple_delayed_request_body(grpc_end2end_test_config config,
config.init_client(f, client_args);
- c = grpc_channel_create_call(f->client, f->client_cq, "/foo",
+ c = grpc_channel_create_call(f->client, f->cq, "/foo",
"foo.test.google.fr", deadline);
GPR_ASSERT(c);
@@ -138,10 +134,10 @@ static void simple_delayed_request_body(grpc_end2end_test_config config,
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f->server, &s, &call_details,
- &request_metadata_recv, f->server_cq,
- f->server_cq, tag(101)));
- cq_expect_completion(v_server, tag(101), 1);
- cq_verify(v_server);
+ &request_metadata_recv, f->cq,
+ f->cq, tag(101)));
+ cq_expect_completion(cqv, tag(101), 1);
+ cq_verify(cqv);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -157,11 +153,9 @@ static void simple_delayed_request_body(grpc_end2end_test_config config,
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(s, ops, op - ops, tag(102)));
- cq_expect_completion(v_server, tag(102), 1);
- cq_verify(v_server);
-
- cq_expect_completion(v_client, tag(1), 1);
- cq_verify(v_client);
+ cq_expect_completion(cqv, tag(102), 1);
+ cq_expect_completion(cqv, tag(1), 1);
+ cq_verify(cqv);
GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED);
GPR_ASSERT(0 == strcmp(details, "xyz"));
@@ -178,8 +172,7 @@ static void simple_delayed_request_body(grpc_end2end_test_config config,
grpc_call_destroy(c);
grpc_call_destroy(s);
- cq_verifier_destroy(v_client);
- cq_verifier_destroy(v_server);
+ cq_verifier_destroy(cqv);
}
static void test_simple_delayed_request_short(grpc_end2end_test_config config) {
diff --git a/test/core/end2end/tests/simple_request.c b/test/core/end2end/tests/simple_request.c
index 98e677900e..be9e414b7c 100644
--- a/test/core/end2end/tests/simple_request.c
+++ b/test/core/end2end/tests/simple_request.c
@@ -91,20 +91,16 @@ static void end_test(grpc_end2end_test_fixture *f) {
shutdown_server(f);
shutdown_client(f);
- grpc_completion_queue_shutdown(f->server_cq);
- drain_cq(f->server_cq);
- grpc_completion_queue_destroy(f->server_cq);
- grpc_completion_queue_shutdown(f->client_cq);
- drain_cq(f->client_cq);
- grpc_completion_queue_destroy(f->client_cq);
+ grpc_completion_queue_shutdown(f->cq);
+ drain_cq(f->cq);
+ grpc_completion_queue_destroy(f->cq);
}
static void simple_request_body(grpc_end2end_test_fixture f) {
grpc_call *c;
grpc_call *s;
gpr_timespec deadline = five_seconds_time();
- cq_verifier *v_client = cq_verifier_create(f.client_cq);
- cq_verifier *v_server = cq_verifier_create(f.server_cq);
+ cq_verifier *cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
grpc_op *op;
grpc_metadata_array initial_metadata_recv;
@@ -116,7 +112,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
size_t details_capacity = 0;
int was_cancelled = 2;
- c = grpc_channel_create_call(f.client, f.client_cq, "/foo",
+ c = grpc_channel_create_call(f.client, f.cq, "/foo",
"foo.test.google.fr:1234", deadline);
GPR_ASSERT(c);
@@ -144,10 +140,10 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f.server, &s, &call_details,
- &request_metadata_recv, f.server_cq,
- f.server_cq, tag(101)));
- cq_expect_completion(v_server, tag(101), 1);
- cq_verify(v_server);
+ &request_metadata_recv, f.cq,
+ f.cq, tag(101)));
+ cq_expect_completion(cqv, tag(101), 1);
+ cq_verify(cqv);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -163,11 +159,9 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(s, ops, op - ops, tag(102)));
- cq_expect_completion(v_server, tag(102), 1);
- cq_verify(v_server);
-
- cq_expect_completion(v_client, tag(1), 1);
- cq_verify(v_client);
+ cq_expect_completion(cqv, tag(102), 1);
+ cq_expect_completion(cqv, tag(1), 1);
+ cq_verify(cqv);
GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED);
GPR_ASSERT(0 == strcmp(details, "xyz"));
@@ -184,8 +178,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
grpc_call_destroy(c);
grpc_call_destroy(s);
- cq_verifier_destroy(v_client);
- cq_verifier_destroy(v_server);
+ cq_verifier_destroy(cqv);
}
static void test_invoke_simple_request(grpc_end2end_test_config config) {
diff --git a/test/core/end2end/tests/simple_request_with_high_initial_sequence_number.c b/test/core/end2end/tests/simple_request_with_high_initial_sequence_number.c
index 3c1a19a5dd..566f971686 100644
--- a/test/core/end2end/tests/simple_request_with_high_initial_sequence_number.c
+++ b/test/core/end2end/tests/simple_request_with_high_initial_sequence_number.c
@@ -91,20 +91,16 @@ static void end_test(grpc_end2end_test_fixture *f) {
shutdown_server(f);
shutdown_client(f);
- grpc_completion_queue_shutdown(f->server_cq);
- drain_cq(f->server_cq);
- grpc_completion_queue_destroy(f->server_cq);
- grpc_completion_queue_shutdown(f->client_cq);
- drain_cq(f->client_cq);
- grpc_completion_queue_destroy(f->client_cq);
+ grpc_completion_queue_shutdown(f->cq);
+ drain_cq(f->cq);
+ grpc_completion_queue_destroy(f->cq);
}
static void simple_request_body(grpc_end2end_test_fixture f) {
grpc_call *c;
grpc_call *s;
gpr_timespec deadline = five_seconds_time();
- cq_verifier *v_client = cq_verifier_create(f.client_cq);
- cq_verifier *v_server = cq_verifier_create(f.server_cq);
+ cq_verifier *cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
grpc_op *op;
grpc_metadata_array initial_metadata_recv;
@@ -116,7 +112,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
size_t details_capacity = 0;
int was_cancelled = 2;
- c = grpc_channel_create_call(f.client, f.client_cq, "/foo",
+ c = grpc_channel_create_call(f.client, f.cq, "/foo",
"foo.test.google.fr:1234", deadline);
GPR_ASSERT(c);
@@ -144,10 +140,10 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f.server, &s, &call_details,
- &request_metadata_recv, f.server_cq,
- f.server_cq, tag(101)));
- cq_expect_completion(v_server, tag(101), 1);
- cq_verify(v_server);
+ &request_metadata_recv, f.cq,
+ f.cq, tag(101)));
+ cq_expect_completion(cqv, tag(101), 1);
+ cq_verify(cqv);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -163,11 +159,9 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(s, ops, op - ops, tag(102)));
- cq_expect_completion(v_server, tag(102), 1);
- cq_verify(v_server);
-
- cq_expect_completion(v_client, tag(1), 1);
- cq_verify(v_client);
+ cq_expect_completion(cqv, tag(102), 1);
+ cq_expect_completion(cqv, tag(1), 1);
+ cq_verify(cqv);
GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED);
GPR_ASSERT(0 == strcmp(details, "xyz"));
@@ -184,8 +178,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
grpc_call_destroy(c);
grpc_call_destroy(s);
- cq_verifier_destroy(v_client);
- cq_verifier_destroy(v_server);
+ cq_verifier_destroy(cqv);
}
static void test_invoke_10_simple_requests(grpc_end2end_test_config config, int initial_sequence_number) {
diff --git a/test/core/httpcli/httpcli_test.c b/test/core/httpcli/httpcli_test.c
index 17a2996baa..7d6838fc70 100644
--- a/test/core/httpcli/httpcli_test.c
+++ b/test/core/httpcli/httpcli_test.c
@@ -40,7 +40,10 @@
#include <grpc/support/sync.h>
#include "test/core/util/test_config.h"
-static gpr_event g_done;
+static gpr_mu g_mu;
+static int g_done = 0;
+static grpc_pollset_set g_pollset_set;
+static grpc_pollset g_pollset;
static gpr_timespec n_seconds_time(int seconds) {
return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(seconds);
@@ -50,22 +53,28 @@ static void on_finish(void *arg, const grpc_httpcli_response *response) {
GPR_ASSERT(arg == (void *)42);
GPR_ASSERT(response);
GPR_ASSERT(response->status == 200);
- gpr_event_set(&g_done, (void *)1);
+ gpr_mu_lock(&g_mu);
+ g_done = 1;
+ gpr_mu_unlock(&g_mu);
}
static void test_get(int use_ssl) {
grpc_httpcli_request req;
+ g_done = 0;
gpr_log(GPR_INFO, "running %s with use_ssl=%d.", __FUNCTION__, use_ssl);
- gpr_event_init(&g_done);
memset(&req, 0, sizeof(req));
req.host = "www.google.com";
req.path = "/";
req.use_ssl = use_ssl;
- grpc_httpcli_get(&req, n_seconds_time(15), on_finish, (void *)42);
- GPR_ASSERT(gpr_event_wait(&g_done, n_seconds_time(20)));
+ grpc_httpcli_get(&req, n_seconds_time(15), &g_pollset_set, on_finish, (void *)42);
+ gpr_mu_lock(&g_mu);
+ while (!g_done) {
+ grpc_pollset_work(&g_pollset, n_seconds_time(20));
+ }
+ gpr_mu_unlock(&g_mu);
}
/*
@@ -89,6 +98,10 @@ static void test_post(int use_ssl) {
int main(int argc, char **argv) {
grpc_test_init(argc, argv);
grpc_iomgr_init();
+ grpc_pollset_set_init(&g_pollset_set);
+ grpc_pollset_init(&g_pollset);
+ gpr_mu_init(&g_mu);
+ grpc_pollset_set_add_pollset(&g_pollset_set, &g_pollset);
test_get(0);
test_get(1);
@@ -96,7 +109,10 @@ int main(int argc, char **argv) {
/* test_post(0); */
/* test_post(1); */
+ grpc_pollset_set_destroy(&g_pollset_set);
+ grpc_pollset_destroy(&g_pollset);
grpc_iomgr_shutdown();
+ gpr_mu_destroy(&g_mu);
return 0;
}
diff --git a/test/core/iomgr/endpoint_tests.c b/test/core/iomgr/endpoint_tests.c
index e63048e26c..d68f8a4f8c 100644
--- a/test/core/iomgr/endpoint_tests.c
+++ b/test/core/iomgr/endpoint_tests.c
@@ -57,6 +57,8 @@
*/
+static grpc_pollset *g_pollset;
+
size_t count_and_unref_slices(gpr_slice *slices, size_t nslices,
int *current_data) {
size_t num_bytes = 0;
@@ -111,8 +113,6 @@ static gpr_slice *allocate_blocks(size_t num_bytes, size_t slice_size,
struct read_and_write_test_state {
grpc_endpoint *read_ep;
grpc_endpoint *write_ep;
- gpr_mu mu;
- gpr_cv cv;
size_t target_bytes;
size_t bytes_read;
size_t current_write_size;
@@ -130,10 +130,10 @@ static void read_and_write_test_read_handler(void *data, gpr_slice *slices,
GPR_ASSERT(error != GRPC_ENDPOINT_CB_ERROR);
if (error == GRPC_ENDPOINT_CB_SHUTDOWN) {
gpr_log(GPR_INFO, "Read handler shutdown");
- gpr_mu_lock(&state->mu);
+ gpr_mu_lock(GRPC_POLLSET_MU(g_pollset));
state->read_done = 1;
- gpr_cv_signal(&state->cv);
- gpr_mu_unlock(&state->mu);
+ grpc_pollset_kick(g_pollset);
+ gpr_mu_unlock(GRPC_POLLSET_MU(g_pollset));
return;
}
@@ -141,10 +141,10 @@ static void read_and_write_test_read_handler(void *data, gpr_slice *slices,
count_and_unref_slices(slices, nslices, &state->current_read_data);
if (state->bytes_read == state->target_bytes) {
gpr_log(GPR_INFO, "Read handler done");
- gpr_mu_lock(&state->mu);
+ gpr_mu_lock(GRPC_POLLSET_MU(g_pollset));
state->read_done = 1;
- gpr_cv_signal(&state->cv);
- gpr_mu_unlock(&state->mu);
+ grpc_pollset_kick(g_pollset);
+ gpr_mu_unlock(GRPC_POLLSET_MU(g_pollset));
} else {
grpc_endpoint_notify_on_read(state->read_ep,
read_and_write_test_read_handler, data);
@@ -164,10 +164,10 @@ static void read_and_write_test_write_handler(void *data,
if (error == GRPC_ENDPOINT_CB_SHUTDOWN) {
gpr_log(GPR_INFO, "Write handler shutdown");
- gpr_mu_lock(&state->mu);
+ gpr_mu_lock(GRPC_POLLSET_MU(g_pollset));
state->write_done = 1;
- gpr_cv_signal(&state->cv);
- gpr_mu_unlock(&state->mu);
+ grpc_pollset_kick(g_pollset);
+ gpr_mu_unlock(GRPC_POLLSET_MU(g_pollset));
return;
}
@@ -198,10 +198,10 @@ static void read_and_write_test_write_handler(void *data,
GPR_ASSERT(state->bytes_written == state->target_bytes);
gpr_log(GPR_INFO, "Write handler done");
- gpr_mu_lock(&state->mu);
+ gpr_mu_lock(GRPC_POLLSET_MU(g_pollset));
state->write_done = 1;
- gpr_cv_signal(&state->cv);
- gpr_mu_unlock(&state->mu);
+ grpc_pollset_kick(g_pollset);
+ gpr_mu_unlock(GRPC_POLLSET_MU(g_pollset));
}
/* Do both reading and writing using the grpc_endpoint API.
@@ -222,9 +222,6 @@ static void read_and_write_test(grpc_endpoint_test_config config,
num_bytes, slice_size);
}
- gpr_mu_init(&state.mu);
- gpr_cv_init(&state.cv);
-
state.read_ep = f.client_ep;
state.write_ep = f.server_ep;
state.target_bytes = num_bytes;
@@ -253,29 +250,24 @@ static void read_and_write_test(grpc_endpoint_test_config config,
grpc_endpoint_shutdown(state.write_ep);
}
- gpr_mu_lock(&state.mu);
+ gpr_mu_lock(GRPC_POLLSET_MU(g_pollset));
while (!state.read_done || !state.write_done) {
- if (gpr_cv_wait(&state.cv, &state.mu, deadline)) {
- gpr_log(GPR_ERROR, "timeout: read_done=%d, write_done=%d",
- state.read_done, state.write_done);
- abort();
- }
+ GPR_ASSERT(gpr_time_cmp(gpr_now(), deadline) < 0);
+ grpc_pollset_work(g_pollset, deadline);
}
- gpr_mu_unlock(&state.mu);
+ gpr_mu_unlock(GRPC_POLLSET_MU(g_pollset));
grpc_endpoint_destroy(state.read_ep);
grpc_endpoint_destroy(state.write_ep);
- gpr_mu_destroy(&state.mu);
- gpr_cv_destroy(&state.cv);
end_test(config);
}
struct timeout_test_state {
- gpr_event io_done;
+ int io_done;
};
typedef struct {
- gpr_event ev;
+ int done;
grpc_endpoint *ep;
} shutdown_during_write_test_state;
@@ -291,7 +283,10 @@ static void shutdown_during_write_test_read_handler(
if (error != GRPC_ENDPOINT_CB_OK) {
grpc_endpoint_destroy(st->ep);
- gpr_event_set(&st->ev, (void *)(gpr_intptr) error);
+ gpr_mu_lock(GRPC_POLLSET_MU(g_pollset));
+ st->done = error;
+ grpc_pollset_kick(g_pollset);
+ gpr_mu_unlock(GRPC_POLLSET_MU(g_pollset));
} else {
grpc_endpoint_notify_on_read(
st->ep, shutdown_during_write_test_read_handler, user_data);
@@ -310,7 +305,10 @@ static void shutdown_during_write_test_write_handler(
gpr_log(GPR_ERROR,
"shutdown_during_write_test_write_handler completed unexpectedly");
}
- gpr_event_set(&st->ev, (void *)(gpr_intptr) 1);
+ gpr_mu_lock(GRPC_POLLSET_MU(g_pollset));
+ st->done = 1;
+ grpc_pollset_kick(g_pollset);
+ gpr_mu_unlock(GRPC_POLLSET_MU(g_pollset));
}
static void shutdown_during_write_test(grpc_endpoint_test_config config,
@@ -329,8 +327,8 @@ static void shutdown_during_write_test(grpc_endpoint_test_config config,
read_st.ep = f.client_ep;
write_st.ep = f.server_ep;
- gpr_event_init(&read_st.ev);
- gpr_event_init(&write_st.ev);
+ read_st.done = 0;
+ write_st.done = 0;
grpc_endpoint_notify_on_read(
read_st.ep, shutdown_during_write_test_read_handler, &read_st);
@@ -347,9 +345,19 @@ static void shutdown_during_write_test(grpc_endpoint_test_config config,
case GRPC_ENDPOINT_WRITE_PENDING:
grpc_endpoint_shutdown(write_st.ep);
deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(10);
- GPR_ASSERT(gpr_event_wait(&write_st.ev, deadline));
+ gpr_mu_lock(GRPC_POLLSET_MU(g_pollset));
+ while (!write_st.done) {
+ GPR_ASSERT(gpr_time_cmp(gpr_now(), deadline) < 0);
+ grpc_pollset_work(g_pollset, deadline);
+ }
+ gpr_mu_unlock(GRPC_POLLSET_MU(g_pollset));
grpc_endpoint_destroy(write_st.ep);
- GPR_ASSERT(gpr_event_wait(&read_st.ev, deadline));
+ gpr_mu_lock(GRPC_POLLSET_MU(g_pollset));
+ while (!read_st.done) {
+ GPR_ASSERT(gpr_time_cmp(gpr_now(), deadline) < 0);
+ grpc_pollset_work(g_pollset, deadline);
+ }
+ gpr_mu_unlock(GRPC_POLLSET_MU(g_pollset));
gpr_free(slices);
end_test(config);
return;
@@ -361,9 +369,11 @@ static void shutdown_during_write_test(grpc_endpoint_test_config config,
abort();
}
-void grpc_endpoint_tests(grpc_endpoint_test_config config) {
+void grpc_endpoint_tests(grpc_endpoint_test_config config, grpc_pollset *pollset) {
+ g_pollset = pollset;
read_and_write_test(config, 10000000, 100000, 8192, 0);
read_and_write_test(config, 1000000, 100000, 1, 0);
read_and_write_test(config, 100000000, 100000, 1, 1);
shutdown_during_write_test(config, 1000);
+ g_pollset = NULL;
}
diff --git a/test/core/iomgr/endpoint_tests.h b/test/core/iomgr/endpoint_tests.h
index 1679d7bd4f..852e71d479 100644
--- a/test/core/iomgr/endpoint_tests.h
+++ b/test/core/iomgr/endpoint_tests.h
@@ -52,6 +52,6 @@ struct grpc_endpoint_test_config {
void (*clean_up)();
};
-void grpc_endpoint_tests(grpc_endpoint_test_config config);
+void grpc_endpoint_tests(grpc_endpoint_test_config config, grpc_pollset *pollset);
#endif /* GRPC_TEST_CORE_IOMGR_ENDPOINT_TESTS_H */
diff --git a/test/core/iomgr/fd_posix_test.c b/test/core/iomgr/fd_posix_test.c
index 57e2c6fc17..207862bd8d 100644
--- a/test/core/iomgr/fd_posix_test.c
+++ b/test/core/iomgr/fd_posix_test.c
@@ -51,6 +51,8 @@
#include <grpc/support/time.h>
#include "test/core/util/test_config.h"
+static grpc_pollset g_pollset;
+
/* buffer size used to send and receive data.
1024 is the minimal value to set TCP send and receive buffer. */
#define BUF_SIZE 1024
@@ -94,16 +96,12 @@ void no_op_cb(void *arg, int success) {}
typedef struct {
grpc_fd *em_fd; /* listening fd */
ssize_t read_bytes_total; /* total number of received bytes */
- gpr_mu mu; /* protect done and done_cv */
- gpr_cv done_cv; /* signaled when a server finishes serving */
int done; /* set to 1 when a server finishes serving */
grpc_iomgr_closure listen_closure;
} server;
static void server_init(server *sv) {
sv->read_bytes_total = 0;
- gpr_mu_init(&sv->mu);
- gpr_cv_init(&sv->done_cv);
sv->done = 0;
}
@@ -179,10 +177,10 @@ static void listen_shutdown_cb(void *arg /*server*/, int success) {
grpc_fd_orphan(sv->em_fd, NULL, NULL);
- gpr_mu_lock(&sv->mu);
+ gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
sv->done = 1;
- gpr_cv_signal(&sv->done_cv);
- gpr_mu_unlock(&sv->mu);
+ grpc_pollset_kick(&g_pollset);
+ gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset));
}
/* Called when a new TCP connection request arrives in the listening port. */
@@ -209,6 +207,7 @@ static void listen_cb(void *arg, /*=sv_arg*/
se = gpr_malloc(sizeof(*se));
se->sv = sv;
se->em_fd = grpc_fd_create(fd);
+ grpc_pollset_add_fd(&g_pollset, se->em_fd);
se->session_read_closure.cb = session_read_cb;
se->session_read_closure.cb_arg = se;
grpc_fd_notify_on_read(se->em_fd, &se->session_read_closure);
@@ -237,6 +236,7 @@ static int server_start(server *sv) {
GPR_ASSERT(listen(fd, MAX_NUM_FD) == 0);
sv->em_fd = grpc_fd_create(fd);
+ grpc_pollset_add_fd(&g_pollset, sv->em_fd);
/* Register to be interested in reading from listen_fd. */
sv->listen_closure.cb = listen_cb;
sv->listen_closure.cb_arg = sv;
@@ -247,12 +247,11 @@ static int server_start(server *sv) {
/* Wait and shutdown a sever. */
static void server_wait_and_shutdown(server *sv) {
- gpr_mu_lock(&sv->mu);
- while (!sv->done) gpr_cv_wait(&sv->done_cv, &sv->mu, gpr_inf_future);
- gpr_mu_unlock(&sv->mu);
-
- gpr_mu_destroy(&sv->mu);
- gpr_cv_destroy(&sv->done_cv);
+ gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
+ while (!sv->done) {
+ grpc_pollset_work(&g_pollset, gpr_inf_future);
+ }
+ gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset));
}
/* ===An upload client to test notify_on_write=== */
@@ -271,8 +270,6 @@ typedef struct {
notify_on_write to schedule another write. */
int client_write_cnt;
- gpr_mu mu; /* protect done and done_cv */
- gpr_cv done_cv; /* signaled when a client finishes sending */
int done; /* set to 1 when a client finishes sending */
grpc_iomgr_closure write_closure;
} client;
@@ -281,8 +278,6 @@ static void client_init(client *cl) {
memset(cl->write_buf, 0, sizeof(cl->write_buf));
cl->write_bytes_total = 0;
cl->client_write_cnt = 0;
- gpr_mu_init(&cl->mu);
- gpr_cv_init(&cl->done_cv);
cl->done = 0;
}
@@ -291,7 +286,7 @@ static void client_session_shutdown_cb(void *arg /*client*/, int success) {
client *cl = arg;
grpc_fd_orphan(cl->em_fd, NULL, NULL);
cl->done = 1;
- gpr_cv_signal(&cl->done_cv);
+ grpc_pollset_kick(&g_pollset);
}
/* Write as much as possible, then register notify_on_write. */
@@ -302,9 +297,9 @@ static void client_session_write(void *arg, /*client*/
ssize_t write_once = 0;
if (!success) {
- gpr_mu_lock(&cl->mu);
+ gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
client_session_shutdown_cb(arg, 1);
- gpr_mu_unlock(&cl->mu);
+ gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset));
return;
}
@@ -314,7 +309,7 @@ static void client_session_write(void *arg, /*client*/
} while (write_once > 0);
if (errno == EAGAIN) {
- gpr_mu_lock(&cl->mu);
+ gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
if (cl->client_write_cnt < CLIENT_TOTAL_WRITE_CNT) {
cl->write_closure.cb = client_session_write;
cl->write_closure.cb_arg = cl;
@@ -323,7 +318,7 @@ static void client_session_write(void *arg, /*client*/
} else {
client_session_shutdown_cb(arg, 1);
}
- gpr_mu_unlock(&cl->mu);
+ gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset));
} else {
gpr_log(GPR_ERROR, "unknown errno %s", strerror(errno));
abort();
@@ -352,18 +347,18 @@ static void client_start(client *cl, int port) {
}
cl->em_fd = grpc_fd_create(fd);
+ grpc_pollset_add_fd(&g_pollset, cl->em_fd);
client_session_write(cl, 1);
}
/* Wait for the signal to shutdown a client. */
static void client_wait_and_shutdown(client *cl) {
- gpr_mu_lock(&cl->mu);
- while (!cl->done) gpr_cv_wait(&cl->done_cv, &cl->mu, gpr_inf_future);
- gpr_mu_unlock(&cl->mu);
-
- gpr_mu_destroy(&cl->mu);
- gpr_cv_destroy(&cl->done_cv);
+ gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
+ while (!cl->done) {
+ grpc_pollset_work(&g_pollset, gpr_inf_future);
+ }
+ gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset));
}
/* Test grpc_fd. Start an upload server and client, upload a stream of
@@ -385,38 +380,32 @@ static void test_grpc_fd(void) {
}
typedef struct fd_change_data {
- gpr_mu mu;
- gpr_cv cv;
void (*cb_that_ran)(void *, int success);
} fd_change_data;
void init_change_data(fd_change_data *fdc) {
- gpr_mu_init(&fdc->mu);
- gpr_cv_init(&fdc->cv);
fdc->cb_that_ran = NULL;
}
void destroy_change_data(fd_change_data *fdc) {
- gpr_mu_destroy(&fdc->mu);
- gpr_cv_destroy(&fdc->cv);
}
static void first_read_callback(void *arg /* fd_change_data */, int success) {
fd_change_data *fdc = arg;
- gpr_mu_lock(&fdc->mu);
+ gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
fdc->cb_that_ran = first_read_callback;
- gpr_cv_signal(&fdc->cv);
- gpr_mu_unlock(&fdc->mu);
+ grpc_pollset_kick(&g_pollset);
+ gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset));
}
static void second_read_callback(void *arg /* fd_change_data */, int success) {
fd_change_data *fdc = arg;
- gpr_mu_lock(&fdc->mu);
+ gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
fdc->cb_that_ran = second_read_callback;
- gpr_cv_signal(&fdc->cv);
- gpr_mu_unlock(&fdc->mu);
+ grpc_pollset_kick(&g_pollset);
+ gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset));
}
/* Test that changing the callback we use for notify_on_read actually works.
@@ -448,6 +437,7 @@ static void test_grpc_fd_change(void) {
GPR_ASSERT(fcntl(sv[1], F_SETFL, flags | O_NONBLOCK) == 0);
em_fd = grpc_fd_create(sv[0]);
+ grpc_pollset_add_fd(&g_pollset, em_fd);
/* Register the first callback, then make its FD readable */
grpc_fd_notify_on_read(em_fd, &first_closure);
@@ -456,12 +446,12 @@ static void test_grpc_fd_change(void) {
GPR_ASSERT(result == 1);
/* And now wait for it to run. */
- gpr_mu_lock(&a.mu);
+ gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
while (a.cb_that_ran == NULL) {
- gpr_cv_wait(&a.cv, &a.mu, gpr_inf_future);
+ grpc_pollset_work(&g_pollset, gpr_inf_future);
}
GPR_ASSERT(a.cb_that_ran == first_read_callback);
- gpr_mu_unlock(&a.mu);
+ gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset));
/* And drain the socket so we can generate a new read edge */
result = read(sv[0], &data, 1);
@@ -474,13 +464,13 @@ static void test_grpc_fd_change(void) {
result = write(sv[1], &data, 1);
GPR_ASSERT(result == 1);
- gpr_mu_lock(&b.mu);
+ gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
while (b.cb_that_ran == NULL) {
- gpr_cv_wait(&b.cv, &b.mu, gpr_inf_future);
+ grpc_pollset_work(&g_pollset, gpr_inf_future);
}
/* Except now we verify that second_read_callback ran instead */
GPR_ASSERT(b.cb_that_ran == second_read_callback);
- gpr_mu_unlock(&b.mu);
+ gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset));
grpc_fd_orphan(em_fd, NULL, NULL);
destroy_change_data(&a);
@@ -488,11 +478,17 @@ static void test_grpc_fd_change(void) {
close(sv[1]);
}
+static void destroy_pollset(void *p) {
+ grpc_pollset_destroy(p);
+}
+
int main(int argc, char **argv) {
grpc_test_init(argc, argv);
grpc_iomgr_init();
+ grpc_pollset_init(&g_pollset);
test_grpc_fd();
test_grpc_fd_change();
+ grpc_pollset_shutdown(&g_pollset, destroy_pollset, &g_pollset);
grpc_iomgr_shutdown();
return 0;
}
diff --git a/test/core/iomgr/tcp_client_posix_test.c b/test/core/iomgr/tcp_client_posix_test.c
index 3c4d8fed4f..945f7c1bdc 100644
--- a/test/core/iomgr/tcp_client_posix_test.c
+++ b/test/core/iomgr/tcp_client_posix_test.c
@@ -45,20 +45,31 @@
#include <grpc/support/time.h>
#include "test/core/util/test_config.h"
+static grpc_pollset_set g_pollset_set;
+static grpc_pollset g_pollset;
+static int g_connections_complete = 0;
+
static gpr_timespec test_deadline(void) {
return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(10);
}
+static void finish_connection() {
+ gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
+ g_connections_complete++;
+ grpc_pollset_kick(&g_pollset);
+ gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset));
+}
+
static void must_succeed(void *arg, grpc_endpoint *tcp) {
GPR_ASSERT(tcp);
grpc_endpoint_shutdown(tcp);
grpc_endpoint_destroy(tcp);
- gpr_event_set(arg, (void *)1);
+ finish_connection();
}
static void must_fail(void *arg, grpc_endpoint *tcp) {
GPR_ASSERT(!tcp);
- gpr_event_set(arg, (void *)1);
+ finish_connection();
}
void test_succeeds(void) {
@@ -66,9 +77,7 @@ void test_succeeds(void) {
socklen_t addr_len = sizeof(addr);
int svr_fd;
int r;
- gpr_event ev;
-
- gpr_event_init(&ev);
+ int connections_complete_before;
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
@@ -79,9 +88,13 @@ void test_succeeds(void) {
GPR_ASSERT(0 == bind(svr_fd, (struct sockaddr *)&addr, addr_len));
GPR_ASSERT(0 == listen(svr_fd, 1));
+ gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
+ connections_complete_before = g_connections_complete;
+ gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset));
+
/* connect to it */
GPR_ASSERT(getsockname(svr_fd, (struct sockaddr *)&addr, &addr_len) == 0);
- grpc_tcp_client_connect(must_succeed, &ev, (struct sockaddr *)&addr, addr_len,
+ grpc_tcp_client_connect(must_succeed, NULL, &g_pollset_set, (struct sockaddr *)&addr, addr_len,
gpr_inf_future);
/* await the connection */
@@ -92,26 +105,39 @@ void test_succeeds(void) {
GPR_ASSERT(r >= 0);
close(r);
- /* wait for the connection callback to finish */
- GPR_ASSERT(gpr_event_wait(&ev, test_deadline()));
+ gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
+
+ while (g_connections_complete == connections_complete_before) {
+ grpc_pollset_work(&g_pollset, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5));
+ }
+
+ gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset));
}
void test_fails(void) {
struct sockaddr_in addr;
socklen_t addr_len = sizeof(addr);
- gpr_event ev;
-
- gpr_event_init(&ev);
+ int connections_complete_before;
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
+ gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
+ connections_complete_before = g_connections_complete;
+ gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset));
+
/* connect to a broken address */
- grpc_tcp_client_connect(must_fail, &ev, (struct sockaddr *)&addr, addr_len,
+ grpc_tcp_client_connect(must_fail, NULL, &g_pollset_set, (struct sockaddr *)&addr, addr_len,
gpr_inf_future);
+ gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
+
/* wait for the connection callback to finish */
- GPR_ASSERT(gpr_event_wait(&ev, test_deadline()));
+ while (g_connections_complete == connections_complete_before) {
+ grpc_pollset_work(&g_pollset, test_deadline());
+ }
+
+ gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset));
}
void test_times_out(void) {
@@ -122,11 +148,9 @@ void test_times_out(void) {
int client_fd[NUM_CLIENT_CONNECTS];
int i;
int r;
- gpr_event ev;
+ int connections_complete_before;
gpr_timespec connect_deadline;
- gpr_event_init(&ev);
-
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
@@ -153,28 +177,48 @@ void test_times_out(void) {
connect_deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(1);
- grpc_tcp_client_connect(must_fail, &ev, (struct sockaddr *)&addr, addr_len,
+ gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
+ connections_complete_before = g_connections_complete;
+ gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset));
+
+ grpc_tcp_client_connect(must_fail, NULL, &g_pollset_set, (struct sockaddr *)&addr, addr_len,
connect_deadline);
+
/* Make sure the event doesn't trigger early */
- GPR_ASSERT(!gpr_event_wait(&ev, GRPC_TIMEOUT_MILLIS_TO_DEADLINE(500)));
- /* Now wait until it should have triggered */
- sleep(1);
+ gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
+ while (gpr_time_cmp(gpr_time_add(connect_deadline, gpr_time_from_seconds(2)), gpr_now()) > 0) {
+ int is_after_deadline = gpr_time_cmp(connect_deadline, gpr_now()) <= 0;
+ if (is_after_deadline && gpr_time_cmp(gpr_time_add(connect_deadline, gpr_time_from_seconds(1)), gpr_now()) > 0) {
+ /* allow some slack before insisting that things be done */
+ } else {
+ GPR_ASSERT(g_connections_complete == connections_complete_before + is_after_deadline);
+ }
+ grpc_pollset_work(&g_pollset, GRPC_TIMEOUT_MILLIS_TO_DEADLINE(10));
+ }
+ gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset));
- /* wait for the connection callback to finish */
- GPR_ASSERT(gpr_event_wait(&ev, test_deadline()));
close(svr_fd);
for (i = 0; i < NUM_CLIENT_CONNECTS; ++i) {
close(client_fd[i]);
}
}
+static void destroy_pollset(void *p) {
+ grpc_pollset_destroy(p);
+}
+
int main(int argc, char **argv) {
grpc_test_init(argc, argv);
grpc_iomgr_init();
+ grpc_pollset_set_init(&g_pollset_set);
+ grpc_pollset_init(&g_pollset);
+ grpc_pollset_set_add_pollset(&g_pollset_set, &g_pollset);
test_succeeds();
gpr_log(GPR_ERROR, "End of first test");
test_fails();
test_times_out();
+ grpc_pollset_set_destroy(&g_pollset_set);
+ grpc_pollset_shutdown(&g_pollset, destroy_pollset, &g_pollset);
grpc_iomgr_shutdown();
return 0;
}
diff --git a/test/core/iomgr/tcp_posix_test.c b/test/core/iomgr/tcp_posix_test.c
index 40abed5f6e..04aed132f4 100644
--- a/test/core/iomgr/tcp_posix_test.c
+++ b/test/core/iomgr/tcp_posix_test.c
@@ -48,6 +48,8 @@
#include "test/core/util/test_config.h"
#include "test/core/iomgr/endpoint_tests.h"
+static grpc_pollset g_pollset;
+
/*
General test notes:
@@ -114,8 +116,6 @@ static size_t fill_socket_partial(int fd, size_t bytes) {
struct read_socket_state {
grpc_endpoint *ep;
- gpr_mu mu;
- gpr_cv cv;
ssize_t read_bytes;
ssize_t target_read_bytes;
};
@@ -145,18 +145,18 @@ static void read_cb(void *user_data, gpr_slice *slices, size_t nslices,
GPR_ASSERT(error == GRPC_ENDPOINT_CB_OK);
- gpr_mu_lock(&state->mu);
+ gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
current_data = state->read_bytes % 256;
read_bytes = count_and_unref_slices(slices, nslices, &current_data);
state->read_bytes += read_bytes;
gpr_log(GPR_INFO, "Read %d bytes of %d", read_bytes,
state->target_read_bytes);
if (state->read_bytes >= state->target_read_bytes) {
- gpr_cv_signal(&state->cv);
+ /* empty */
} else {
grpc_endpoint_notify_on_read(state->ep, read_cb, state);
}
- gpr_mu_unlock(&state->mu);
+ gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset));
}
/* Write to a socket, then read from it using the grpc_tcp API. */
@@ -173,31 +173,25 @@ static void read_test(ssize_t num_bytes, ssize_t slice_size) {
create_sockets(sv);
ep = grpc_tcp_create(grpc_fd_create(sv[1]), slice_size);
+ grpc_endpoint_add_to_pollset(ep, &g_pollset);
+
written_bytes = fill_socket_partial(sv[0], num_bytes);
gpr_log(GPR_INFO, "Wrote %d bytes", written_bytes);
- gpr_mu_init(&state.mu);
- gpr_cv_init(&state.cv);
state.ep = ep;
state.read_bytes = 0;
state.target_read_bytes = written_bytes;
grpc_endpoint_notify_on_read(ep, read_cb, &state);
- gpr_mu_lock(&state.mu);
- for (;;) {
- GPR_ASSERT(gpr_cv_wait(&state.cv, &state.mu, deadline) == 0);
- if (state.read_bytes >= state.target_read_bytes) {
- break;
- }
+ gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
+ while (state.read_bytes < state.target_read_bytes) {
+ grpc_pollset_work(&g_pollset, deadline);
}
GPR_ASSERT(state.read_bytes == state.target_read_bytes);
- gpr_mu_unlock(&state.mu);
+ gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset));
grpc_endpoint_destroy(ep);
-
- gpr_mu_destroy(&state.mu);
- gpr_cv_destroy(&state.cv);
}
/* Write to a socket until it fills up, then read from it using the grpc_tcp
@@ -214,37 +208,28 @@ static void large_read_test(ssize_t slice_size) {
create_sockets(sv);
ep = grpc_tcp_create(grpc_fd_create(sv[1]), slice_size);
+ grpc_endpoint_add_to_pollset(ep, &g_pollset);
written_bytes = fill_socket(sv[0]);
gpr_log(GPR_INFO, "Wrote %d bytes", written_bytes);
- gpr_mu_init(&state.mu);
- gpr_cv_init(&state.cv);
state.ep = ep;
state.read_bytes = 0;
state.target_read_bytes = written_bytes;
grpc_endpoint_notify_on_read(ep, read_cb, &state);
- gpr_mu_lock(&state.mu);
- for (;;) {
- GPR_ASSERT(gpr_cv_wait(&state.cv, &state.mu, deadline) == 0);
- if (state.read_bytes >= state.target_read_bytes) {
- break;
- }
+ gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
+ while (state.read_bytes < state.target_read_bytes) {
+ grpc_pollset_work(&g_pollset, deadline);
}
GPR_ASSERT(state.read_bytes == state.target_read_bytes);
- gpr_mu_unlock(&state.mu);
+ gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset));
grpc_endpoint_destroy(ep);
-
- gpr_mu_destroy(&state.mu);
- gpr_cv_destroy(&state.cv);
}
struct write_socket_state {
grpc_endpoint *ep;
- gpr_mu mu;
- gpr_cv cv;
int write_done;
};
@@ -275,11 +260,11 @@ static void write_done(void *user_data /* write_socket_state */,
grpc_endpoint_cb_status error) {
struct write_socket_state *state = (struct write_socket_state *)user_data;
gpr_log(GPR_INFO, "Write done callback called");
- gpr_mu_lock(&state->mu);
+ gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
gpr_log(GPR_INFO, "Signalling write done");
state->write_done = 1;
- gpr_cv_signal(&state->cv);
- gpr_mu_unlock(&state->mu);
+ grpc_pollset_kick(&g_pollset);
+ gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset));
}
void drain_socket_blocking(int fd, size_t num_bytes, size_t read_size) {
@@ -294,6 +279,9 @@ void drain_socket_blocking(int fd, size_t num_bytes, size_t read_size) {
GPR_ASSERT(fcntl(fd, F_SETFL, flags & ~O_NONBLOCK) == 0);
for (;;) {
+ gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
+ grpc_pollset_work(&g_pollset, GRPC_TIMEOUT_MILLIS_TO_DEADLINE(10));
+ gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset));
do {
bytes_read =
read(fd, buf, bytes_left > read_size ? read_size : bytes_left);
@@ -351,9 +339,8 @@ static void write_test(ssize_t num_bytes, ssize_t slice_size) {
create_sockets(sv);
ep = grpc_tcp_create(grpc_fd_create(sv[1]), GRPC_TCP_DEFAULT_READ_SLICE_SIZE);
+ grpc_endpoint_add_to_pollset(ep, &g_pollset);
- gpr_mu_init(&state.mu);
- gpr_cv_init(&state.cv);
state.ep = ep;
state.write_done = 0;
@@ -366,19 +353,17 @@ static void write_test(ssize_t num_bytes, ssize_t slice_size) {
GPR_ASSERT(read_bytes == num_bytes);
} else {
drain_socket_blocking(sv[0], num_bytes, num_bytes);
- gpr_mu_lock(&state.mu);
+ gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
for (;;) {
if (state.write_done) {
break;
}
- GPR_ASSERT(gpr_cv_wait(&state.cv, &state.mu, deadline) == 0);
+ grpc_pollset_work(&g_pollset, deadline);
}
- gpr_mu_unlock(&state.mu);
+ gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset));
}
grpc_endpoint_destroy(ep);
- gpr_mu_destroy(&state.mu);
- gpr_cv_destroy(&state.cv);
gpr_free(slices);
}
@@ -407,10 +392,9 @@ static void write_error_test(ssize_t num_bytes, ssize_t slice_size) {
create_sockets(sv);
ep = grpc_tcp_create(grpc_fd_create(sv[1]), GRPC_TCP_DEFAULT_READ_SLICE_SIZE);
+ grpc_endpoint_add_to_pollset(ep, &g_pollset);
close(sv[0]);
- gpr_mu_init(&state.mu);
- gpr_cv_init(&state.cv);
state.ep = ep;
state.write_done = 0;
@@ -423,20 +407,18 @@ static void write_error_test(ssize_t num_bytes, ssize_t slice_size) {
break;
case GRPC_ENDPOINT_WRITE_PENDING:
grpc_endpoint_notify_on_read(ep, read_done_for_write_error, NULL);
- gpr_mu_lock(&state.mu);
+ gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
for (;;) {
if (state.write_done) {
break;
}
- GPR_ASSERT(gpr_cv_wait(&state.cv, &state.mu, deadline) == 0);
+ grpc_pollset_work(&g_pollset, deadline);
}
- gpr_mu_unlock(&state.mu);
+ gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset));
break;
}
grpc_endpoint_destroy(ep);
- gpr_mu_destroy(&state.mu);
- gpr_cv_destroy(&state.cv);
free(slices);
}
@@ -475,6 +457,8 @@ static grpc_endpoint_test_fixture create_fixture_tcp_socketpair(
create_sockets(sv);
f.client_ep = grpc_tcp_create(grpc_fd_create(sv[0]), slice_size);
f.server_ep = grpc_tcp_create(grpc_fd_create(sv[1]), slice_size);
+ grpc_endpoint_add_to_pollset(f.client_ep, &g_pollset);
+ grpc_endpoint_add_to_pollset(f.server_ep, &g_pollset);
return f;
}
@@ -483,11 +467,17 @@ static grpc_endpoint_test_config configs[] = {
{"tcp/tcp_socketpair", create_fixture_tcp_socketpair, clean_up},
};
+static void destroy_pollset(void *p) {
+ grpc_pollset_destroy(p);
+}
+
int main(int argc, char **argv) {
grpc_test_init(argc, argv);
grpc_init();
+ grpc_pollset_init(&g_pollset);
run_tests();
- grpc_endpoint_tests(configs[0]);
+ grpc_endpoint_tests(configs[0], &g_pollset);
+ grpc_pollset_shutdown(&g_pollset, destroy_pollset, &g_pollset);
grpc_shutdown();
return 0;
diff --git a/test/core/iomgr/tcp_server_posix_test.c b/test/core/iomgr/tcp_server_posix_test.c
index 1c02c4b2f8..c644c29931 100644
--- a/test/core/iomgr/tcp_server_posix_test.c
+++ b/test/core/iomgr/tcp_server_posix_test.c
@@ -45,18 +45,17 @@
#define LOG_TEST() gpr_log(GPR_INFO, "%s", __FUNCTION__)
-static gpr_mu mu;
-static gpr_cv cv;
-static int nconnects = 0;
+static grpc_pollset g_pollset;
+static int g_nconnects = 0;
static void on_connect(void *arg, grpc_endpoint *tcp) {
grpc_endpoint_shutdown(tcp);
grpc_endpoint_destroy(tcp);
- gpr_mu_lock(&mu);
- nconnects++;
- gpr_cv_broadcast(&cv);
- gpr_mu_unlock(&mu);
+ gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
+ g_nconnects++;
+ grpc_pollset_kick(&g_pollset);
+ gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset));
}
static void test_no_op(void) {
@@ -106,12 +105,11 @@ static void test_connect(int n) {
grpc_tcp_server *s = grpc_tcp_server_create();
int nconnects_before;
gpr_timespec deadline;
+ grpc_pollset *pollsets[1];
int i;
LOG_TEST();
gpr_log(GPR_INFO, "clients=%d", n);
- gpr_mu_lock(&mu);
-
memset(&addr, 0, sizeof(addr));
addr.ss_family = AF_INET;
GPR_ASSERT(grpc_tcp_server_add_port(s, (struct sockaddr *)&addr, addr_len));
@@ -121,38 +119,43 @@ static void test_connect(int n) {
GPR_ASSERT(getsockname(svrfd, (struct sockaddr *)&addr, &addr_len) == 0);
GPR_ASSERT(addr_len <= sizeof(addr));
- grpc_tcp_server_start(s, NULL, 0, on_connect, NULL);
+ pollsets[0] = &g_pollset;
+ grpc_tcp_server_start(s, pollsets, 1, on_connect, NULL);
+
+ gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
for (i = 0; i < n; i++) {
- deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(1);
+ deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(4000);
- nconnects_before = nconnects;
+ nconnects_before = g_nconnects;
clifd = socket(addr.ss_family, SOCK_STREAM, 0);
GPR_ASSERT(clifd >= 0);
+ gpr_log(GPR_DEBUG, "start connect");
GPR_ASSERT(connect(clifd, (struct sockaddr *)&addr, addr_len) == 0);
- while (nconnects == nconnects_before) {
- GPR_ASSERT(gpr_cv_wait(&cv, &mu, deadline) == 0);
+ gpr_log(GPR_DEBUG, "wait");
+ while (g_nconnects == nconnects_before && gpr_time_cmp(deadline, gpr_now()) > 0) {
+ grpc_pollset_work(&g_pollset, deadline);
}
+ gpr_log(GPR_DEBUG, "wait done");
- GPR_ASSERT(nconnects == nconnects_before + 1);
+ GPR_ASSERT(g_nconnects == nconnects_before + 1);
close(clifd);
-
- if (i != n - 1) {
- sleep(1);
- }
}
- gpr_mu_unlock(&mu);
+ gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset));
grpc_tcp_server_destroy(s, NULL, NULL);
}
+static void destroy_pollset(void *p) {
+ grpc_pollset_destroy(p);
+}
+
int main(int argc, char **argv) {
grpc_test_init(argc, argv);
grpc_iomgr_init();
- gpr_mu_init(&mu);
- gpr_cv_init(&cv);
+ grpc_pollset_init(&g_pollset);
test_no_op();
test_no_op_with_start();
@@ -161,8 +164,7 @@ int main(int argc, char **argv) {
test_connect(1);
test_connect(10);
+ grpc_pollset_shutdown(&g_pollset, destroy_pollset, &g_pollset);
grpc_iomgr_shutdown();
- gpr_mu_destroy(&mu);
- gpr_cv_destroy(&cv);
return 0;
}
diff --git a/test/core/security/secure_endpoint_test.c b/test/core/security/secure_endpoint_test.c
index 6477454e8a..28c909f34d 100644
--- a/test/core/security/secure_endpoint_test.c
+++ b/test/core/security/secure_endpoint_test.c
@@ -44,6 +44,8 @@
#include "test/core/util/test_config.h"
#include "src/core/tsi/fake_transport_security.h"
+static grpc_pollset g_pollset;
+
static grpc_endpoint_test_fixture secure_endpoint_create_fixture_tcp_socketpair(
size_t slice_size, gpr_slice *leftover_slices, size_t leftover_nslices) {
tsi_frame_protector *fake_read_protector = tsi_create_fake_protector(NULL);
@@ -52,6 +54,8 @@ static grpc_endpoint_test_fixture secure_endpoint_create_fixture_tcp_socketpair(
grpc_endpoint_pair tcp;
tcp = grpc_iomgr_create_endpoint_pair(slice_size);
+ grpc_endpoint_add_to_pollset(tcp.client, &g_pollset);
+ grpc_endpoint_add_to_pollset(tcp.server, &g_pollset);
if (leftover_nslices == 0) {
f.client_ep =
@@ -190,13 +194,19 @@ static void test_destroy_ep_early(grpc_endpoint_test_config config,
clean_up();
}
+static void destroy_pollset(void *p) {
+ grpc_pollset_destroy(p);
+}
+
int main(int argc, char **argv) {
grpc_test_init(argc, argv);
grpc_iomgr_init();
- grpc_endpoint_tests(configs[0]);
+ grpc_pollset_init(&g_pollset);
+ grpc_endpoint_tests(configs[0], &g_pollset);
test_leftover(configs[1], 1);
test_destroy_ep_early(configs[1], 1);
+ grpc_pollset_shutdown(&g_pollset, destroy_pollset, &g_pollset);
grpc_iomgr_shutdown();
return 0;
diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc
index 24595a820f..507fc7a710 100644
--- a/test/cpp/end2end/async_end2end_test.cc
+++ b/test/cpp/end2end/async_end2end_test.cc
@@ -67,27 +67,45 @@ namespace {
void* tag(int i) { return (void*)(gpr_intptr) i; }
-void verify_ok(CompletionQueue* cq, int i, bool expect_ok) {
- bool ok;
- void* got_tag;
- EXPECT_TRUE(cq->Next(&got_tag, &ok));
- EXPECT_EQ(expect_ok, ok);
- EXPECT_EQ(tag(i), got_tag);
-}
-
-void verify_timed_ok(
- CompletionQueue* cq, int i, bool expect_ok,
- std::chrono::system_clock::time_point deadline =
- std::chrono::system_clock::time_point::max(),
- CompletionQueue::NextStatus expected_outcome = CompletionQueue::GOT_EVENT) {
- bool ok;
- void* got_tag;
- EXPECT_EQ(cq->AsyncNext(&got_tag, &ok, deadline), expected_outcome);
- if (expected_outcome == CompletionQueue::GOT_EVENT) {
- EXPECT_EQ(expect_ok, ok);
- EXPECT_EQ(tag(i), got_tag);
+class Verifier {
+ public:
+ Verifier& Expect(int i, bool expect_ok) {
+ expectations_[tag(i)] = expect_ok;
+ return *this;
}
-}
+ void Verify(CompletionQueue *cq) {
+ GPR_ASSERT(!expectations_.empty());
+ while (!expectations_.empty()) {
+ bool ok;
+ void* got_tag;
+ EXPECT_TRUE(cq->Next(&got_tag, &ok));
+ auto it = expectations_.find(got_tag);
+ EXPECT_TRUE(it != expectations_.end());
+ EXPECT_EQ(it->second, ok);
+ expectations_.erase(it);
+ }
+ }
+ void Verify(CompletionQueue *cq, std::chrono::system_clock::time_point deadline) {
+ if (expectations_.empty()) {
+ bool ok;
+ void *got_tag;
+ EXPECT_EQ(cq->AsyncNext(&got_tag, &ok, deadline), CompletionQueue::TIMEOUT);
+ } else {
+ while (!expectations_.empty()) {
+ bool ok;
+ void *got_tag;
+ EXPECT_EQ(cq->AsyncNext(&got_tag, &ok, deadline), CompletionQueue::GOT_EVENT);
+ auto it = expectations_.find(got_tag);
+ EXPECT_TRUE(it != expectations_.end());
+ EXPECT_EQ(it->second, ok);
+ expectations_.erase(it);
+ }
+ }
+ }
+
+ private:
+ std::map<void*, bool> expectations_;
+};
class AsyncEnd2endTest : public ::testing::Test {
protected:
@@ -100,7 +118,7 @@ class AsyncEnd2endTest : public ::testing::Test {
ServerBuilder builder;
builder.AddListeningPort(server_address_.str(), grpc::InsecureServerCredentials());
builder.RegisterAsyncService(&service_);
- srv_cq_ = builder.AddCompletionQueue();
+ cq_ = builder.AddCompletionQueue();
server_ = builder.BuildAndStart();
}
@@ -108,11 +126,8 @@ class AsyncEnd2endTest : public ::testing::Test {
server_->Shutdown();
void* ignored_tag;
bool ignored_ok;
- cli_cq_.Shutdown();
- srv_cq_->Shutdown();
- while (cli_cq_.Next(&ignored_tag, &ignored_ok))
- ;
- while (srv_cq_->Next(&ignored_tag, &ignored_ok))
+ cq_->Shutdown();
+ while (cq_->Next(&ignored_tag, &ignored_ok))
;
}
@@ -122,11 +137,6 @@ class AsyncEnd2endTest : public ::testing::Test {
stub_ = std::move(grpc::cpp::test::util::TestService::NewStub(channel));
}
- void server_ok(int i) { verify_ok(srv_cq_.get(), i, true); }
- void client_ok(int i) { verify_ok(&cli_cq_, i, true); }
- void server_fail(int i) { verify_ok(srv_cq_.get(), i, false); }
- void client_fail(int i) { verify_ok(&cli_cq_, i, false); }
-
void SendRpc(int num_rpcs) {
for (int i = 0; i < num_rpcs; i++) {
EchoRequest send_request;
@@ -141,28 +151,27 @@ class AsyncEnd2endTest : public ::testing::Test {
send_request.set_message("Hello");
std::unique_ptr<ClientAsyncResponseReader<EchoResponse> > response_reader(
- stub_->AsyncEcho(&cli_ctx, send_request, &cli_cq_));
+ stub_->AsyncEcho(&cli_ctx, send_request, cq_.get()));
service_.RequestEcho(&srv_ctx, &recv_request, &response_writer,
- srv_cq_.get(), srv_cq_.get(), tag(2));
+ cq_.get(), cq_.get(), tag(2));
- server_ok(2);
+ Verifier().Expect(2, true).Verify(cq_.get());
EXPECT_EQ(send_request.message(), recv_request.message());
send_response.set_message(recv_request.message());
response_writer.Finish(send_response, Status::OK, tag(3));
- server_ok(3);
+ Verifier().Expect(3, true).Verify(cq_.get());
response_reader->Finish(&recv_response, &recv_status, tag(4));
- client_ok(4);
+ Verifier().Expect(4, true).Verify(cq_.get());
EXPECT_EQ(send_response.message(), recv_response.message());
EXPECT_TRUE(recv_status.IsOk());
}
}
- CompletionQueue cli_cq_;
- std::unique_ptr<ServerCompletionQueue> srv_cq_;
+ std::unique_ptr<ServerCompletionQueue> cq_;
std::unique_ptr<grpc::cpp::test::util::TestService::Stub> stub_;
std::unique_ptr<Server> server_;
grpc::cpp::test::util::TestService::AsyncService service_;
@@ -195,27 +204,27 @@ TEST_F(AsyncEnd2endTest, AsyncNextRpc) {
send_request.set_message("Hello");
std::unique_ptr<ClientAsyncResponseReader<EchoResponse> > response_reader(
- stub_->AsyncEcho(&cli_ctx, send_request, &cli_cq_));
+ stub_->AsyncEcho(&cli_ctx, send_request, cq_.get()));
std::chrono::system_clock::time_point time_now(
std::chrono::system_clock::now());
std::chrono::system_clock::time_point time_limit(
std::chrono::system_clock::now() + std::chrono::seconds(10));
- verify_timed_ok(srv_cq_.get(), -1, true, time_now, CompletionQueue::TIMEOUT);
- verify_timed_ok(&cli_cq_, -1, true, time_now, CompletionQueue::TIMEOUT);
+ Verifier().Verify(cq_.get(), time_now);
+ Verifier().Verify(cq_.get(), time_now);
- service_.RequestEcho(&srv_ctx, &recv_request, &response_writer, srv_cq_.get(),
- srv_cq_.get(), tag(2));
+ service_.RequestEcho(&srv_ctx, &recv_request, &response_writer, cq_.get(),
+ cq_.get(), tag(2));
- verify_timed_ok(srv_cq_.get(), 2, true, time_limit);
+ Verifier().Expect(2, true).Verify(cq_.get(), time_limit);
EXPECT_EQ(send_request.message(), recv_request.message());
send_response.set_message(recv_request.message());
response_writer.Finish(send_response, Status::OK, tag(3));
- verify_timed_ok(srv_cq_.get(), 3, true);
+ Verifier().Expect(3, true).Verify(cq_.get(), std::chrono::system_clock::time_point::max());
response_reader->Finish(&recv_response, &recv_status, tag(4));
- verify_timed_ok(&cli_cq_, 4, true);
+ Verifier().Expect(4, true).Verify(cq_.get(), std::chrono::system_clock::time_point::max());
EXPECT_EQ(send_response.message(), recv_response.message());
EXPECT_TRUE(recv_status.IsOk());
@@ -236,40 +245,39 @@ TEST_F(AsyncEnd2endTest, SimpleClientStreaming) {
send_request.set_message("Hello");
std::unique_ptr<ClientAsyncWriter<EchoRequest> > cli_stream(
- stub_->AsyncRequestStream(&cli_ctx, &recv_response, &cli_cq_, tag(1)));
+ stub_->AsyncRequestStream(&cli_ctx, &recv_response, cq_.get(), tag(1)));
- service_.RequestRequestStream(&srv_ctx, &srv_stream, srv_cq_.get(),
- srv_cq_.get(), tag(2));
+ service_.RequestRequestStream(&srv_ctx, &srv_stream, cq_.get(),
+ cq_.get(), tag(2));
- server_ok(2);
- client_ok(1);
+ Verifier().Expect(2, true).Expect(1, true).Verify(cq_.get());
cli_stream->Write(send_request, tag(3));
- client_ok(3);
+ Verifier().Expect(3, true).Verify(cq_.get());
srv_stream.Read(&recv_request, tag(4));
- server_ok(4);
+ Verifier().Expect(4, true).Verify(cq_.get());
EXPECT_EQ(send_request.message(), recv_request.message());
cli_stream->Write(send_request, tag(5));
- client_ok(5);
+ Verifier().Expect(5, true).Verify(cq_.get());
srv_stream.Read(&recv_request, tag(6));
- server_ok(6);
+ Verifier().Expect(6, true).Verify(cq_.get());
EXPECT_EQ(send_request.message(), recv_request.message());
cli_stream->WritesDone(tag(7));
- client_ok(7);
+ Verifier().Expect(7, true).Verify(cq_.get());
srv_stream.Read(&recv_request, tag(8));
- server_fail(8);
+ Verifier().Expect(8, false).Verify(cq_.get());
send_response.set_message(recv_request.message());
srv_stream.Finish(send_response, Status::OK, tag(9));
- server_ok(9);
+ Verifier().Expect(9, true).Verify(cq_.get());
cli_stream->Finish(&recv_status, tag(10));
- client_ok(10);
+ Verifier().Expect(10, true).Verify(cq_.get());
EXPECT_EQ(send_response.message(), recv_response.message());
EXPECT_TRUE(recv_status.IsOk());
@@ -290,38 +298,37 @@ TEST_F(AsyncEnd2endTest, SimpleServerStreaming) {
send_request.set_message("Hello");
std::unique_ptr<ClientAsyncReader<EchoResponse> > cli_stream(
- stub_->AsyncResponseStream(&cli_ctx, send_request, &cli_cq_, tag(1)));
+ stub_->AsyncResponseStream(&cli_ctx, send_request, cq_.get(), tag(1)));
service_.RequestResponseStream(&srv_ctx, &recv_request, &srv_stream,
- srv_cq_.get(), srv_cq_.get(), tag(2));
+ cq_.get(), cq_.get(), tag(2));
- server_ok(2);
- client_ok(1);
+ Verifier().Expect(1, true).Expect(2, true).Verify(cq_.get());
EXPECT_EQ(send_request.message(), recv_request.message());
send_response.set_message(recv_request.message());
srv_stream.Write(send_response, tag(3));
- server_ok(3);
+ Verifier().Expect(3, true).Verify(cq_.get());
cli_stream->Read(&recv_response, tag(4));
- client_ok(4);
+ Verifier().Expect(4, true).Verify(cq_.get());
EXPECT_EQ(send_response.message(), recv_response.message());
srv_stream.Write(send_response, tag(5));
- server_ok(5);
+ Verifier().Expect(5, true).Verify(cq_.get());
cli_stream->Read(&recv_response, tag(6));
- client_ok(6);
+ Verifier().Expect(6, true).Verify(cq_.get());
EXPECT_EQ(send_response.message(), recv_response.message());
srv_stream.Finish(Status::OK, tag(7));
- server_ok(7);
+ Verifier().Expect(7, true).Verify(cq_.get());
cli_stream->Read(&recv_response, tag(8));
- client_fail(8);
+ Verifier().Expect(8, false).Verify(cq_.get());
cli_stream->Finish(&recv_status, tag(9));
- client_ok(9);
+ Verifier().Expect(9, true).Verify(cq_.get());
EXPECT_TRUE(recv_status.IsOk());
}
@@ -341,40 +348,39 @@ TEST_F(AsyncEnd2endTest, SimpleBidiStreaming) {
send_request.set_message("Hello");
std::unique_ptr<ClientAsyncReaderWriter<EchoRequest, EchoResponse> >
- cli_stream(stub_->AsyncBidiStream(&cli_ctx, &cli_cq_, tag(1)));
+ cli_stream(stub_->AsyncBidiStream(&cli_ctx, cq_.get(), tag(1)));
- service_.RequestBidiStream(&srv_ctx, &srv_stream, srv_cq_.get(),
- srv_cq_.get(), tag(2));
+ service_.RequestBidiStream(&srv_ctx, &srv_stream, cq_.get(),
+ cq_.get(), tag(2));
- server_ok(2);
- client_ok(1);
+ Verifier().Expect(1, true).Expect(2, true).Verify(cq_.get());
cli_stream->Write(send_request, tag(3));
- client_ok(3);
+ Verifier().Expect(3, true).Verify(cq_.get());
srv_stream.Read(&recv_request, tag(4));
- server_ok(4);
+ Verifier().Expect(4, true).Verify(cq_.get());
EXPECT_EQ(send_request.message(), recv_request.message());
send_response.set_message(recv_request.message());
srv_stream.Write(send_response, tag(5));
- server_ok(5);
+ Verifier().Expect(5, true).Verify(cq_.get());
cli_stream->Read(&recv_response, tag(6));
- client_ok(6);
+ Verifier().Expect(6, true).Verify(cq_.get());
EXPECT_EQ(send_response.message(), recv_response.message());
cli_stream->WritesDone(tag(7));
- client_ok(7);
+ Verifier().Expect(7, true).Verify(cq_.get());
srv_stream.Read(&recv_request, tag(8));
- server_fail(8);
+ Verifier().Expect(8, false).Verify(cq_.get());
srv_stream.Finish(Status::OK, tag(9));
- server_ok(9);
+ Verifier().Expect(9, true).Verify(cq_.get());
cli_stream->Finish(&recv_status, tag(10));
- client_ok(10);
+ Verifier().Expect(10, true).Verify(cq_.get());
EXPECT_TRUE(recv_status.IsOk());
}
@@ -400,11 +406,11 @@ TEST_F(AsyncEnd2endTest, ClientInitialMetadataRpc) {
cli_ctx.AddMetadata(meta2.first, meta2.second);
std::unique_ptr<ClientAsyncResponseReader<EchoResponse> > response_reader(
- stub_->AsyncEcho(&cli_ctx, send_request, &cli_cq_));
+ stub_->AsyncEcho(&cli_ctx, send_request, cq_.get()));
- service_.RequestEcho(&srv_ctx, &recv_request, &response_writer, srv_cq_.get(),
- srv_cq_.get(), tag(2));
- server_ok(2);
+ service_.RequestEcho(&srv_ctx, &recv_request, &response_writer, cq_.get(),
+ cq_.get(), tag(2));
+ Verifier().Expect(2, true).Verify(cq_.get());
EXPECT_EQ(send_request.message(), recv_request.message());
auto client_initial_metadata = srv_ctx.client_metadata();
EXPECT_EQ(meta1.second, client_initial_metadata.find(meta1.first)->second);
@@ -414,10 +420,10 @@ TEST_F(AsyncEnd2endTest, ClientInitialMetadataRpc) {
send_response.set_message(recv_request.message());
response_writer.Finish(send_response, Status::OK, tag(3));
- server_ok(3);
+ Verifier().Expect(3, true).Verify(cq_.get());
response_reader->Finish(&recv_response, &recv_status, tag(4));
- client_ok(4);
+ Verifier().Expect(4, true).Verify(cq_.get());
EXPECT_EQ(send_response.message(), recv_response.message());
EXPECT_TRUE(recv_status.IsOk());
@@ -441,19 +447,19 @@ TEST_F(AsyncEnd2endTest, ServerInitialMetadataRpc) {
std::pair<grpc::string, grpc::string> meta2("key2", "val2");
std::unique_ptr<ClientAsyncResponseReader<EchoResponse> > response_reader(
- stub_->AsyncEcho(&cli_ctx, send_request, &cli_cq_));
+ stub_->AsyncEcho(&cli_ctx, send_request, cq_.get()));
- service_.RequestEcho(&srv_ctx, &recv_request, &response_writer, srv_cq_.get(),
- srv_cq_.get(), tag(2));
- server_ok(2);
+ service_.RequestEcho(&srv_ctx, &recv_request, &response_writer, cq_.get(),
+ cq_.get(), tag(2));
+ Verifier().Expect(2, true).Verify(cq_.get());
EXPECT_EQ(send_request.message(), recv_request.message());
srv_ctx.AddInitialMetadata(meta1.first, meta1.second);
srv_ctx.AddInitialMetadata(meta2.first, meta2.second);
response_writer.SendInitialMetadata(tag(3));
- server_ok(3);
+ Verifier().Expect(3, true).Verify(cq_.get());
response_reader->ReadInitialMetadata(tag(4));
- client_ok(4);
+ Verifier().Expect(4, true).Verify(cq_.get());
auto server_initial_metadata = cli_ctx.GetServerInitialMetadata();
EXPECT_EQ(meta1.second, server_initial_metadata.find(meta1.first)->second);
EXPECT_EQ(meta2.second, server_initial_metadata.find(meta2.first)->second);
@@ -461,10 +467,10 @@ TEST_F(AsyncEnd2endTest, ServerInitialMetadataRpc) {
send_response.set_message(recv_request.message());
response_writer.Finish(send_response, Status::OK, tag(5));
- server_ok(5);
+ Verifier().Expect(5, true).Verify(cq_.get());
response_reader->Finish(&recv_response, &recv_status, tag(6));
- client_ok(6);
+ Verifier().Expect(6, true).Verify(cq_.get());
EXPECT_EQ(send_response.message(), recv_response.message());
EXPECT_TRUE(recv_status.IsOk());
@@ -488,24 +494,24 @@ TEST_F(AsyncEnd2endTest, ServerTrailingMetadataRpc) {
std::pair<grpc::string, grpc::string> meta2("key2", "val2");
std::unique_ptr<ClientAsyncResponseReader<EchoResponse> > response_reader(
- stub_->AsyncEcho(&cli_ctx, send_request, &cli_cq_));
+ stub_->AsyncEcho(&cli_ctx, send_request, cq_.get()));
- service_.RequestEcho(&srv_ctx, &recv_request, &response_writer, srv_cq_.get(),
- srv_cq_.get(), tag(2));
- server_ok(2);
+ service_.RequestEcho(&srv_ctx, &recv_request, &response_writer, cq_.get(),
+ cq_.get(), tag(2));
+ Verifier().Expect(2, true).Verify(cq_.get());
EXPECT_EQ(send_request.message(), recv_request.message());
response_writer.SendInitialMetadata(tag(3));
- server_ok(3);
+ Verifier().Expect(3, true).Verify(cq_.get());
send_response.set_message(recv_request.message());
srv_ctx.AddTrailingMetadata(meta1.first, meta1.second);
srv_ctx.AddTrailingMetadata(meta2.first, meta2.second);
response_writer.Finish(send_response, Status::OK, tag(4));
- server_ok(4);
+ Verifier().Expect(4, true).Verify(cq_.get());
response_reader->Finish(&recv_response, &recv_status, tag(5));
- client_ok(5);
+ Verifier().Expect(5, true).Verify(cq_.get());
EXPECT_EQ(send_response.message(), recv_response.message());
EXPECT_TRUE(recv_status.IsOk());
auto server_trailing_metadata = cli_ctx.GetServerTrailingMetadata();
@@ -548,11 +554,11 @@ TEST_F(AsyncEnd2endTest, MetadataRpc) {
cli_ctx.AddMetadata(meta2.first, meta2.second);
std::unique_ptr<ClientAsyncResponseReader<EchoResponse> > response_reader(
- stub_->AsyncEcho(&cli_ctx, send_request, &cli_cq_));
+ stub_->AsyncEcho(&cli_ctx, send_request, cq_.get()));
- service_.RequestEcho(&srv_ctx, &recv_request, &response_writer, srv_cq_.get(),
- srv_cq_.get(), tag(2));
- server_ok(2);
+ service_.RequestEcho(&srv_ctx, &recv_request, &response_writer, cq_.get(),
+ cq_.get(), tag(2));
+ Verifier().Expect(2, true).Verify(cq_.get());
EXPECT_EQ(send_request.message(), recv_request.message());
auto client_initial_metadata = srv_ctx.client_metadata();
EXPECT_EQ(meta1.second, client_initial_metadata.find(meta1.first)->second);
@@ -562,9 +568,9 @@ TEST_F(AsyncEnd2endTest, MetadataRpc) {
srv_ctx.AddInitialMetadata(meta3.first, meta3.second);
srv_ctx.AddInitialMetadata(meta4.first, meta4.second);
response_writer.SendInitialMetadata(tag(3));
- server_ok(3);
+ Verifier().Expect(3, true).Verify(cq_.get());
response_reader->ReadInitialMetadata(tag(4));
- client_ok(4);
+ Verifier().Expect(4, true).Verify(cq_.get());
auto server_initial_metadata = cli_ctx.GetServerInitialMetadata();
EXPECT_EQ(meta3.second, server_initial_metadata.find(meta3.first)->second);
EXPECT_EQ(meta4.second, server_initial_metadata.find(meta4.first)->second);
@@ -575,10 +581,10 @@ TEST_F(AsyncEnd2endTest, MetadataRpc) {
srv_ctx.AddTrailingMetadata(meta6.first, meta6.second);
response_writer.Finish(send_response, Status::OK, tag(5));
- server_ok(5);
+ Verifier().Expect(5, true).Verify(cq_.get());
response_reader->Finish(&recv_response, &recv_status, tag(6));
- client_ok(6);
+ Verifier().Expect(6, true).Verify(cq_.get());
EXPECT_EQ(send_response.message(), recv_response.message());
EXPECT_TRUE(recv_status.IsOk());
auto server_trailing_metadata = cli_ctx.GetServerTrailingMetadata();
diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py
index 6d3f6ca1f6..ccae1e1e9d 100755
--- a/tools/run_tests/run_tests.py
+++ b/tools/run_tests/run_tests.py
@@ -334,9 +334,9 @@ argp.add_argument('--newline_on_success',
action='store_const',
const=True)
argp.add_argument('-l', '--language',
- choices=sorted(_LANGUAGES.keys()),
+ choices=['all'] + sorted(_LANGUAGES.keys()),
nargs='+',
- default=sorted(_LANGUAGES.keys()))
+ default=['all'])
args = argp.parse_args()
# grab config
@@ -347,7 +347,10 @@ run_configs = set(_CONFIGS[cfg]
build_configs = set(cfg.build_config for cfg in run_configs)
make_targets = []
-languages = set(_LANGUAGES[l] for l in args.language)
+languages = set(_LANGUAGES[l]
+ for l in itertools.chain.from_iterable(
+ _LANGUAGES.iterkeys() if x == 'all' else [x]
+ for x in args.language))
if len(build_configs) > 1:
for language in languages:
@@ -379,8 +382,8 @@ build_steps.extend(set(
one_run = set(
spec
for config in run_configs
- for language in args.language
- for spec in _LANGUAGES[language].test_specs(config, args.travis)
+ for language in languages
+ for spec in language.test_specs(config, args.travis)
if re.search(args.regex, spec.shortname))
runs_per_test = args.runs_per_test
diff --git a/vsprojects/grpc/grpc.vcxproj b/vsprojects/grpc/grpc.vcxproj
index e6c474541d..f215cf9993 100644
--- a/vsprojects/grpc/grpc.vcxproj
+++ b/vsprojects/grpc/grpc.vcxproj
@@ -199,6 +199,8 @@
<ClInclude Include="..\..\src\core\iomgr\pollset_kick_posix.h" />
<ClInclude Include="..\..\src\core\iomgr\pollset_kick_windows.h" />
<ClInclude Include="..\..\src\core\iomgr\pollset_posix.h" />
+ <ClInclude Include="..\..\src\core\iomgr\pollset_set_posix.h" />
+ <ClInclude Include="..\..\src\core\iomgr\pollset_set_windows.h" />
<ClInclude Include="..\..\src\core\iomgr\pollset_windows.h" />
<ClInclude Include="..\..\src\core\iomgr\resolve_address.h" />
<ClInclude Include="..\..\src\core\iomgr\sockaddr.h" />
@@ -356,6 +358,10 @@
</ClCompile>
<ClCompile Include="..\..\src\core\iomgr\pollset_posix.c">
</ClCompile>
+ <ClCompile Include="..\..\src\core\iomgr\pollset_set_posix.c">
+ </ClCompile>
+ <ClCompile Include="..\..\src\core\iomgr\pollset_set_windows.c">
+ </ClCompile>
<ClCompile Include="..\..\src\core\iomgr\pollset_windows.c">
</ClCompile>
<ClCompile Include="..\..\src\core\iomgr\resolve_address_posix.c">
diff --git a/vsprojects/grpc/grpc.vcxproj.filters b/vsprojects/grpc/grpc.vcxproj.filters
index ef9387dd2a..ed19f19a31 100644
--- a/vsprojects/grpc/grpc.vcxproj.filters
+++ b/vsprojects/grpc/grpc.vcxproj.filters
@@ -145,6 +145,12 @@
<ClCompile Include="..\..\src\core\iomgr\pollset_posix.c">
<Filter>src\core\iomgr</Filter>
</ClCompile>
+ <ClCompile Include="..\..\src\core\iomgr\pollset_set_posix.c">
+ <Filter>src\core\iomgr</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\core\iomgr\pollset_set_windows.c">
+ <Filter>src\core\iomgr</Filter>
+ </ClCompile>
<ClCompile Include="..\..\src\core\iomgr\pollset_windows.c">
<Filter>src\core\iomgr</Filter>
</ClCompile>
@@ -509,6 +515,12 @@
<ClInclude Include="..\..\src\core\iomgr\pollset_posix.h">
<Filter>src\core\iomgr</Filter>
</ClInclude>
+ <ClInclude Include="..\..\src\core\iomgr\pollset_set_posix.h">
+ <Filter>src\core\iomgr</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\core\iomgr\pollset_set_windows.h">
+ <Filter>src\core\iomgr</Filter>
+ </ClInclude>
<ClInclude Include="..\..\src\core\iomgr\pollset_windows.h">
<Filter>src\core\iomgr</Filter>
</ClInclude>
diff --git a/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj b/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj
index c1572259ab..27f0018e76 100644
--- a/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj
+++ b/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj
@@ -181,6 +181,8 @@
<ClInclude Include="..\..\src\core\iomgr\pollset_kick_posix.h" />
<ClInclude Include="..\..\src\core\iomgr\pollset_kick_windows.h" />
<ClInclude Include="..\..\src\core\iomgr\pollset_posix.h" />
+ <ClInclude Include="..\..\src\core\iomgr\pollset_set_posix.h" />
+ <ClInclude Include="..\..\src\core\iomgr\pollset_set_windows.h" />
<ClInclude Include="..\..\src\core\iomgr\pollset_windows.h" />
<ClInclude Include="..\..\src\core\iomgr\resolve_address.h" />
<ClInclude Include="..\..\src\core\iomgr\sockaddr.h" />
@@ -298,6 +300,10 @@
</ClCompile>
<ClCompile Include="..\..\src\core\iomgr\pollset_posix.c">
</ClCompile>
+ <ClCompile Include="..\..\src\core\iomgr\pollset_set_posix.c">
+ </ClCompile>
+ <ClCompile Include="..\..\src\core\iomgr\pollset_set_windows.c">
+ </ClCompile>
<ClCompile Include="..\..\src\core\iomgr\pollset_windows.c">
</ClCompile>
<ClCompile Include="..\..\src\core\iomgr\resolve_address_posix.c">
diff --git a/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters b/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters
index 0bee095da3..8dae709dcb 100644
--- a/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters
+++ b/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters
@@ -85,6 +85,12 @@
<ClCompile Include="..\..\src\core\iomgr\pollset_posix.c">
<Filter>src\core\iomgr</Filter>
</ClCompile>
+ <ClCompile Include="..\..\src\core\iomgr\pollset_set_posix.c">
+ <Filter>src\core\iomgr</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\core\iomgr\pollset_set_windows.c">
+ <Filter>src\core\iomgr</Filter>
+ </ClCompile>
<ClCompile Include="..\..\src\core\iomgr\pollset_windows.c">
<Filter>src\core\iomgr</Filter>
</ClCompile>
@@ -398,6 +404,12 @@
<ClInclude Include="..\..\src\core\iomgr\pollset_posix.h">
<Filter>src\core\iomgr</Filter>
</ClInclude>
+ <ClInclude Include="..\..\src\core\iomgr\pollset_set_posix.h">
+ <Filter>src\core\iomgr</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\core\iomgr\pollset_set_windows.h">
+ <Filter>src\core\iomgr</Filter>
+ </ClInclude>
<ClInclude Include="..\..\src\core\iomgr\pollset_windows.h">
<Filter>src\core\iomgr</Filter>
</ClInclude>