aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/end2end/fixtures/h2_uchannel.c
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2016-02-19 16:22:44 -0800
committerGravatar Craig Tiller <ctiller@google.com>2016-02-19 16:22:44 -0800
commita8be91b3153fc75a425718799130172357507dd3 (patch)
tree94a9b0e1936ff743805c0876aa7de97b6ca4d14e /test/core/end2end/fixtures/h2_uchannel.c
parent3633ce48a9ec540c9608d2a7e773d4e1113bb1e1 (diff)
Provide an interface firewall between pollset and its implementations
Starting to allow for >1 implementation of pollset within a binary. Do so without requiring an extra allocation for completion queues (which we could not tolerate).
Diffstat (limited to 'test/core/end2end/fixtures/h2_uchannel.c')
-rw-r--r--test/core/end2end/fixtures/h2_uchannel.c39
1 files changed, 21 insertions, 18 deletions
diff --git a/test/core/end2end/fixtures/h2_uchannel.c b/test/core/end2end/fixtures/h2_uchannel.c
index 33055561cb..f363b60cba 100644
--- a/test/core/end2end/fixtures/h2_uchannel.c
+++ b/test/core/end2end/fixtures/h2_uchannel.c
@@ -35,6 +35,13 @@
#include <string.h>
+#include <grpc/support/alloc.h>
+#include <grpc/support/host_port.h>
+#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
+#include <grpc/support/sync.h>
+#include <grpc/support/thd.h>
+#include <grpc/support/useful.h>
#include "src/core/channel/channel_args.h"
#include "src/core/channel/client_channel.h"
#include "src/core/channel/client_uchannel.h"
@@ -46,13 +53,6 @@
#include "src/core/surface/channel.h"
#include "src/core/surface/server.h"
#include "src/core/transport/chttp2_transport.h"
-#include <grpc/support/alloc.h>
-#include <grpc/support/host_port.h>
-#include <grpc/support/log.h>
-#include <grpc/support/string_util.h>
-#include <grpc/support/sync.h>
-#include <grpc/support/thd.h>
-#include <grpc/support/useful.h>
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
@@ -253,30 +253,33 @@ static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *arg, bool success) {
}
static grpc_connected_subchannel *connect_subchannel(grpc_subchannel *c) {
- grpc_pollset pollset;
+ gpr_mu mu;
+ gpr_mu_init(&mu);
+ grpc_pollset *pollset = gpr_malloc(grpc_pollset_size());
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_pollset_init(&pollset);
+ grpc_pollset_init(pollset, &mu);
grpc_pollset_set_init(&g_interested_parties);
- grpc_pollset_set_add_pollset(&exec_ctx, &g_interested_parties, &pollset);
+ grpc_pollset_set_add_pollset(&exec_ctx, &g_interested_parties, pollset);
grpc_subchannel_notify_on_state_change(&exec_ctx, c, &g_interested_parties,
&g_state,
grpc_closure_create(state_changed, c));
grpc_exec_ctx_flush(&exec_ctx);
- gpr_mu_lock(GRPC_POLLSET_MU(&pollset));
+ gpr_mu_lock(&mu);
while (g_state != GRPC_CHANNEL_READY) {
grpc_pollset_worker *worker = NULL;
- grpc_pollset_work(&exec_ctx, &pollset, &worker,
- gpr_now(GPR_CLOCK_MONOTONIC),
+ grpc_pollset_work(&exec_ctx, pollset, &worker, gpr_now(GPR_CLOCK_MONOTONIC),
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(1));
- gpr_mu_unlock(GRPC_POLLSET_MU(&pollset));
+ gpr_mu_unlock(&mu);
grpc_exec_ctx_flush(&exec_ctx);
- gpr_mu_lock(GRPC_POLLSET_MU(&pollset));
+ gpr_mu_lock(&mu);
}
- grpc_pollset_shutdown(&exec_ctx, &pollset,
- grpc_closure_create(destroy_pollset, &pollset));
+ grpc_pollset_shutdown(&exec_ctx, pollset,
+ grpc_closure_create(destroy_pollset, pollset));
grpc_pollset_set_destroy(&g_interested_parties);
- gpr_mu_unlock(GRPC_POLLSET_MU(&pollset));
+ gpr_mu_unlock(&mu);
grpc_exec_ctx_finish(&exec_ctx);
+ gpr_free(pollset);
+ gpr_mu_destroy(&mu);
return grpc_subchannel_get_connected_subchannel(c);
}