Change barriers to protect the innocent

pull/1259/head
Craig Tiller 10 years ago
parent 9fa41b92e0
commit 1ae46a2129
  1. 4
      src/core/transport/metadata.c

@ -475,7 +475,7 @@ grpc_mdelem *grpc_mdelem_ref(grpc_mdelem *gmd) {
this function - meaning that no adjustment to mdtab_free is necessary, this function - meaning that no adjustment to mdtab_free is necessary,
simplifying the logic here to be just an atomic increment */ simplifying the logic here to be just an atomic increment */
/* use C assert to have this removed in opt builds */ /* use C assert to have this removed in opt builds */
assert(gpr_atm_acq_load(&md->refcnt) >= 1); assert(gpr_atm_no_barrier_load(&md->refcnt) >= 1);
gpr_atm_no_barrier_fetch_add(&md->refcnt, 1); gpr_atm_no_barrier_fetch_add(&md->refcnt, 1);
return gmd; return gmd;
} }
@ -484,7 +484,7 @@ void grpc_mdelem_unref(grpc_mdelem *gmd) {
internal_metadata *md = (internal_metadata *)gmd; internal_metadata *md = (internal_metadata *)gmd;
grpc_mdctx *ctx = md->context; grpc_mdctx *ctx = md->context;
lock(ctx); lock(ctx);
assert(gpr_atm_acq_load(&md->refcnt) >= 1); assert(gpr_atm_nobarrier_load(&md->refcnt) >= 1);
if (1 == gpr_atm_full_fetch_add(&md->refcnt, -1)) { if (1 == gpr_atm_full_fetch_add(&md->refcnt, -1)) {
ctx->mdtab_free++; ctx->mdtab_free++;
} }

Loading…
Cancel
Save