aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2016-07-08 17:08:57 -0700
committerGravatar Craig Tiller <ctiller@google.com>2016-07-08 17:08:57 -0700
commit8d8d0d3d10709fe3413f5112531d89a5531203e7 (patch)
tree5890921266b5cb0163c6c333c629a79f9350202e
parenta36857da24b126300234f86450a61b7b2a7d0daa (diff)
Get combiner finalization lists working
-rw-r--r--src/core/lib/iomgr/closure.c4
-rw-r--r--test/core/iomgr/combiner_test.c17
2 files changed, 18 insertions, 3 deletions
diff --git a/src/core/lib/iomgr/closure.c b/src/core/lib/iomgr/closure.c
index 0b6c3b2539..1ba0a5c141 100644
--- a/src/core/lib/iomgr/closure.c
+++ b/src/core/lib/iomgr/closure.c
@@ -41,6 +41,10 @@ void grpc_closure_init(grpc_closure *closure, grpc_iomgr_cb_func cb,
closure->cb_arg = cb_arg;
}
+void grpc_closure_list_init(grpc_closure_list *closure_list) {
+ closure_list->head = closure_list->tail = NULL;
+}
+
void grpc_closure_list_append(grpc_closure_list *closure_list,
grpc_closure *closure, grpc_error *error) {
if (closure == NULL) {
diff --git a/test/core/iomgr/combiner_test.c b/test/core/iomgr/combiner_test.c
index d9f7601722..0aaeada345 100644
--- a/test/core/iomgr/combiner_test.c
+++ b/test/core/iomgr/combiner_test.c
@@ -120,16 +120,27 @@ static void test_execute_many(void) {
grpc_combiner_destroy(lock);
}
+static bool got_in_finally = false;
+
+static void in_finally(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
+ got_in_finally = true;
+}
+
+static void add_finally(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
+ grpc_combiner_execute_finally(exec_ctx, arg,
+ grpc_closure_create(in_finally, NULL),
+ GRPC_ERROR_NONE, false);
+}
+
static void test_execute_finally(void) {
gpr_log(GPR_DEBUG, "test_execute_finally");
grpc_combiner *lock = grpc_combiner_create(NULL);
- bool done = false;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_combiner_execute(&exec_ctx, lock, grpc_closure_create(add_finally, lock),
GRPC_ERROR_NONE);
grpc_exec_ctx_finish(&exec_ctx);
- GPR_ASSERT(done);
+ GPR_ASSERT(got_in_finally);
grpc_combiner_destroy(lock);
}
@@ -138,8 +149,8 @@ int main(int argc, char **argv) {
grpc_init();
test_no_op();
test_execute_one();
- test_execute_many();
test_execute_finally();
+ test_execute_many();
grpc_shutdown();
return 0;