From 959d6541d15081cf758b7513ddba9bcb4711b9ea Mon Sep 17 00:00:00 2001
From: Craig Tiller <ctiller@google.com>
Date: Thu, 22 Sep 2016 16:15:27 -0700
Subject: [PATCH] Fix tests to run

---
 src/core/lib/iomgr/buffer_pool.c   | 14 +++++++++-----
 test/core/iomgr/buffer_pool_test.c |  2 ++
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/core/lib/iomgr/buffer_pool.c b/src/core/lib/iomgr/buffer_pool.c
index 8e3cd1608e..b0d617bf7e 100644
--- a/src/core/lib/iomgr/buffer_pool.c
+++ b/src/core/lib/iomgr/buffer_pool.c
@@ -281,6 +281,7 @@ static void bu_destroy(grpc_exec_ctx *exec_ctx, void *bu, grpc_error *error) {
                       GRPC_ERROR_CANCELLED, NULL);
   grpc_exec_ctx_sched(exec_ctx, buffer_user->on_done_destroy, GRPC_ERROR_NONE,
                       NULL);
+  grpc_buffer_pool_internal_unref(exec_ctx, buffer_user->buffer_pool);
 }
 
 typedef struct {
@@ -351,7 +352,7 @@ void grpc_buffer_pool_resize(grpc_buffer_pool *buffer_pool, size_t size) {
   a->size = (int64_t)size;
   grpc_closure_init(&a->closure, bp_resize, a);
   grpc_combiner_execute(&exec_ctx, buffer_pool->combiner, &a->closure,
-                        GRPC_ERROR_NONE);
+                        GRPC_ERROR_NONE, false);
   grpc_exec_ctx_finish(&exec_ctx);
 }
 
@@ -376,6 +377,8 @@ void grpc_buffer_user_init(grpc_buffer_user *buffer_user,
   grpc_closure_list_init(&buffer_user->on_allocated);
   buffer_user->allocating = false;
   buffer_user->added_to_free_pool = false;
+  buffer_user->reclaimers[0] = NULL;
+  buffer_user->reclaimers[1] = NULL;
   for (int i = 0; i < GRPC_BULIST_COUNT; i++) {
     buffer_user->links[i].next = buffer_user->links[i].prev = NULL;
   }
@@ -386,7 +389,7 @@ void grpc_buffer_user_destroy(grpc_exec_ctx *exec_ctx,
                               grpc_closure *on_done) {
   buffer_user->on_done_destroy = on_done;
   grpc_combiner_execute(exec_ctx, buffer_user->buffer_pool->combiner,
-                        &buffer_user->destroy_closure, GRPC_ERROR_NONE);
+                        &buffer_user->destroy_closure, GRPC_ERROR_NONE, false);
 }
 
 void grpc_buffer_user_alloc(grpc_exec_ctx *exec_ctx,
@@ -401,7 +404,8 @@ void grpc_buffer_user_alloc(grpc_exec_ctx *exec_ctx,
     if (!buffer_user->allocating) {
       buffer_user->allocating = true;
       grpc_combiner_execute(exec_ctx, buffer_user->buffer_pool->combiner,
-                            &buffer_user->allocate_closure, GRPC_ERROR_NONE);
+                            &buffer_user->allocate_closure, GRPC_ERROR_NONE,
+                            false);
     }
   } else {
     grpc_exec_ctx_sched(exec_ctx, optional_on_done, GRPC_ERROR_NONE, NULL);
@@ -422,7 +426,7 @@ void grpc_buffer_user_free(grpc_exec_ctx *exec_ctx,
     buffer_user->added_to_free_pool = true;
     grpc_combiner_execute(exec_ctx, buffer_user->buffer_pool->combiner,
                           &buffer_user->add_to_free_pool_closure,
-                          GRPC_ERROR_NONE);
+                          GRPC_ERROR_NONE, false);
   }
   gpr_mu_unlock(&buffer_user->mu);
 }
@@ -434,5 +438,5 @@ void grpc_buffer_user_post_reclaimer(grpc_exec_ctx *exec_ctx,
   buffer_user->reclaimers[destructive] = closure;
   grpc_combiner_execute(exec_ctx, buffer_user->buffer_pool->combiner,
                         &buffer_user->post_reclaimer_closure[destructive],
-                        GRPC_ERROR_NONE);
+                        GRPC_ERROR_NONE, false);
 }
diff --git a/test/core/iomgr/buffer_pool_test.c b/test/core/iomgr/buffer_pool_test.c
index 7993d94100..689f8c2c31 100644
--- a/test/core/iomgr/buffer_pool_test.c
+++ b/test/core/iomgr/buffer_pool_test.c
@@ -74,6 +74,7 @@ static void test_buffer_user_no_op(void) {
 static void test_instant_alloc_then_free(void) {
   gpr_log(GPR_INFO, "** test_instant_alloc_then_free **");
   grpc_buffer_pool *p = grpc_buffer_pool_create();
+  grpc_buffer_pool_resize(p, 1024 * 1024);
   grpc_buffer_user usr;
   grpc_buffer_user_init(&usr, p);
   {
@@ -93,6 +94,7 @@ static void test_instant_alloc_then_free(void) {
 static void test_instant_alloc_free_pair(void) {
   gpr_log(GPR_INFO, "** test_instant_alloc_free_pair **");
   grpc_buffer_pool *p = grpc_buffer_pool_create();
+  grpc_buffer_pool_resize(p, 1024 * 1024);
   grpc_buffer_user usr;
   grpc_buffer_user_init(&usr, p);
   {
-- 
GitLab