aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib/surface
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2017-05-26 09:09:39 -0700
committerGravatar Craig Tiller <ctiller@google.com>2017-05-26 09:09:39 -0700
commit1e960fc80aed7bc391bed720202ff4f4e39b9a5b (patch)
treece0f143b57af9a2272be1b048dad42409c1f95b6 /src/core/lib/surface
parent6f0bd2c00dc2e049b32e9ee8ca28d6a5c97719ea (diff)
Attempt to reduce locks
Diffstat (limited to 'src/core/lib/surface')
-rw-r--r--src/core/lib/surface/completion_queue.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/core/lib/surface/completion_queue.c b/src/core/lib/surface/completion_queue.c
index 59d2eb53b7..42e2e72710 100644
--- a/src/core/lib/surface/completion_queue.c
+++ b/src/core/lib/surface/completion_queue.c
@@ -581,22 +581,20 @@ static void cq_end_op_for_next(grpc_exec_ctx *exec_ctx,
/* Add the completion to the queue */
bool is_first = cq_event_queue_push(&cqd->queue, storage);
gpr_atm_no_barrier_fetch_add(&cqd->things_queued_ever, 1);
+ bool shutdown = gpr_unref(&cqd->pending_events);
- gpr_mu_lock(cqd->mu);
-
- int shutdown = gpr_unref(&cqd->pending_events);
if (!shutdown) {
/* Only kick if this is the first item queued */
- grpc_error *kick_error =
- is_first ? cq->poller_vtable->kick(POLLSET_FROM_CQ(cq), NULL)
- : GRPC_ERROR_NONE;
- gpr_mu_unlock(cqd->mu);
-
- if (kick_error != GRPC_ERROR_NONE) {
- const char *msg = grpc_error_string(kick_error);
- gpr_log(GPR_ERROR, "Kick failed: %s", msg);
+ if (is_first) {
+ gpr_mu_lock(cqd->mu);
+ grpc_error *kick_error = cq->poller_vtable->kick(POLLSET_FROM_CQ(cq);
+ gpr_mu_unlock(cqd->mu);
- GRPC_ERROR_UNREF(kick_error);
+ if (kick_error != GRPC_ERROR_NONE) {
+ const char *msg = grpc_error_string(kick_error);
+ gpr_log(GPR_ERROR, "Kick failed: %s", msg);
+ GRPC_ERROR_UNREF(kick_error);
+ }
}
} else {
cq_finish_shutdown(exec_ctx, cq);