summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2024-05-27 17:03:00 -0700
committerGarrett D'Amore <garrett@damore.org>2024-05-30 07:28:48 -0700
commit76707668e3593094e1c5e675691b11230a565a1e (patch)
treedb61d231daa7856191f77ad852fcfd932066a663
parenta233f55c780d9138a12e616d826003252b1122c9 (diff)
downloadnng-76707668e3593094e1c5e675691b11230a565a1e.tar.gz
nng-76707668e3593094e1c5e675691b11230a565a1e.tar.bz2
nng-76707668e3593094e1c5e675691b11230a565a1e.zip
Safer initialization of aios
-rw-r--r--src/core/aio.c28
1 files changed, 1 insertions, 27 deletions
diff --git a/src/core/aio.c b/src/core/aio.c
index 9a21d224..27ec6d9c 100644
--- a/src/core/aio.c
+++ b/src/core/aio.c
@@ -70,28 +70,6 @@ static int nni_aio_expire_q_cnt;
// operations from starting, without waiting for any existing one to
// complete, call nni_aio_close.
-// In some places we want to check that an aio is not in use.
-// Technically if these checks pass, then they should not need
-// to be done with a lock, because the caller should have the only
-// references to them. However, race detectors can't necessarily
-// know about this semantic, and may complain about potential data
-// races. To suppress false positives, define NNG_RACE_DETECTOR.
-// Note that this will cause extra locks to be acquired, affecting
-// performance, so don't use it in production.
-#ifdef __has_feature
-#if __has_feature(thread_sanitizer)
-#define NNG_RACE_DETECTOR
-#endif
-#endif
-
-#ifdef NNG_RACE_DETECTOR
-#define aio_safe_lock(l) nni_mtx_lock(l)
-#define aio_safe_unlock(l) nni_mtx_unlock(l)
-#else
-#define aio_safe_lock(l) ((void) 1)
-#define aio_safe_unlock(l) ((void) 1)
-#endif
-
static nni_reap_list aio_reap_list = {
.rl_offset = offsetof(nni_aio, a_reap_node),
.rl_func = (nni_cb) nni_aio_free,
@@ -350,8 +328,7 @@ nni_aio_begin(nni_aio *aio)
// checks may wish ignore or suppress these checks.
nni_aio_expire_q *eq = aio->a_expire_q;
- aio_safe_lock(&eq->eq_mtx);
-
+ nni_mtx_lock(&eq->eq_mtx);
NNI_ASSERT(!nni_aio_list_active(aio));
NNI_ASSERT(aio->a_cancel_fn == NULL);
NNI_ASSERT(!nni_list_node_active(&aio->a_expire_node));
@@ -365,9 +342,6 @@ nni_aio_begin(nni_aio *aio)
aio->a_count = 0;
aio->a_cancel_fn = NULL;
- aio_safe_unlock(&eq->eq_mtx);
-
- nni_mtx_lock(&eq->eq_mtx);
// We should not reschedule anything at this point.
if (aio->a_stop) {
aio->a_result = NNG_ECANCELED;