From abfaf2a5363aefdda8f5b311d1e46833aca06e53 Mon Sep 17 00:00:00 2001 From: Craig Tiller <craig.tiller@gmail.com> Date: Thu, 16 Jul 2015 17:23:40 -0700 Subject: [PATCH] Expand comment --- src/core/iomgr/pollset_posix.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/core/iomgr/pollset_posix.c b/src/core/iomgr/pollset_posix.c index 3c35fcb89f..9b4a2006a1 100644 --- a/src/core/iomgr/pollset_posix.c +++ b/src/core/iomgr/pollset_posix.c @@ -106,8 +106,11 @@ void grpc_pollset_init(grpc_pollset *pollset) { void grpc_pollset_add_fd(grpc_pollset *pollset, grpc_fd *fd) { gpr_mu_lock(&pollset->mu); pollset->vtable->add_fd(pollset, fd, 1); + /* the following (enabled only in debug) will reacquire and then releast + our lock - meaning that if the unlocking flag passed to del_fd above is + not respected, the code will deadlock (in a way that we have a chance of + debugging) */ #ifndef NDEBUG - /* this will deadlock if the unlocking rules aren't correctly implemented */ gpr_mu_lock(&pollset->mu); gpr_mu_unlock(&pollset->mu); #endif @@ -116,8 +119,11 @@ void grpc_pollset_add_fd(grpc_pollset *pollset, grpc_fd *fd) { void grpc_pollset_del_fd(grpc_pollset *pollset, grpc_fd *fd) { gpr_mu_lock(&pollset->mu); pollset->vtable->del_fd(pollset, fd, 1); -#ifndef NDEBUG - /* this will deadlock if the unlocking rules aren't correctly implemented */ + /* the following (enabled only in debug) will reacquire and then releast + our lock - meaning that if the unlocking flag passed to del_fd above is + not respected, the code will deadlock (in a way that we have a chance of + debugging) */ +#ifndef NDEBUG gpr_mu_lock(&pollset->mu); gpr_mu_unlock(&pollset->mu); #endif -- GitLab