diff options
author | Eric Wong <e@80x24.org> | 2022-11-20 09:14:22 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2022-12-02 09:40:01 +0000 |
commit | 43ba0b5a8fde89e594d677b5f14946a0cae6d961 (patch) | |
tree | df06e8f2b43db3ea2ef61a5d4409099c93b454cc | |
parent | a604f91b061139a236c9f6d734ff0b174dcb5c24 (diff) | |
download | mwrap-43ba0b5a8fde89e594d677b5f14946a0cae6d961.tar.gz |
We no longer need to unlock in this function if it fails, and asserting rcu_read_ongoing() is a good idea to ensure cds_lfht_lookup() is used properly.
-rw-r--r-- | mwrap_core.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/mwrap_core.h b/mwrap_core.h index 09b7930..291a078 100644 --- a/mwrap_core.h +++ b/mwrap_core.h @@ -226,7 +226,8 @@ static struct src_loc *totals_add_rcu(struct src_loc *k) again: t = CMM_LOAD_SHARED(totals); - if (!t) goto out_unlock; + if (!t) return l; + assert(rcu_read_ongoing()); cds_lfht_lookup(t, k->hval, loc_eq, k, &iter); cur = cds_lfht_iter_get_node(&iter); if (cur) { @@ -236,7 +237,7 @@ again: } else { size_t n = loc_size(k); l = real_malloc(sizeof(*l) + n); - if (!l) goto out_unlock; + if (!l) return l; memcpy(l, k, sizeof(*l) + n); l->mtx = mutex_assign(); l->age_total = 0; @@ -252,7 +253,6 @@ again: goto again; } } -out_unlock: return l; } |