aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2017-04-05 12:09:23 -0700
committerGravatar GitHub <noreply@github.com>2017-04-05 12:09:23 -0700
commitf8af6d9cf8d461ff3d93490583760c1f089452b6 (patch)
treefc2dfb8db85cc76cd2ba6dd2c6c1ca7bc00ae580 /src
parent3aa7e1bd3b1d6ab4b0b942fdec07f56fa21861d2 (diff)
parent0df90f049ad8ee0da6e47bbe89650fcf9bee25e2 (diff)
Merge pull request #10364 from ctiller/lazy-batches
Lazily create batch control structures
Diffstat (limited to 'src')
-rw-r--r--src/core/lib/surface/call.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/core/lib/surface/call.c b/src/core/lib/surface/call.c
index 87787b3eea..c37ead2318 100644
--- a/src/core/lib/surface/call.c
+++ b/src/core/lib/surface/call.c
@@ -175,7 +175,7 @@ struct grpc_call {
/* have we received initial metadata */
bool has_initial_md_been_received;
- batch_control active_batches[MAX_CONCURRENT_BATCHES];
+ batch_control *active_batches[MAX_CONCURRENT_BATCHES];
grpc_transport_stream_op_batch_payload stream_op_payload;
/* first idx: is_receiving, second idx: is_trailing */
@@ -1034,7 +1034,11 @@ static batch_control *allocate_batch_control(grpc_call *call,
const grpc_op *ops,
size_t num_ops) {
int slot = batch_slot_for_op(ops[0].op);
- batch_control *bctl = &call->active_batches[slot];
+ batch_control **pslot = &call->active_batches[slot];
+ if (*pslot == NULL) {
+ *pslot = gpr_arena_alloc(call->arena, sizeof(batch_control));
+ }
+ batch_control *bctl = *pslot;
if (bctl->call != NULL) {
return NULL;
}