• David Symonds's avatar
    Use the mutex in exvar.Set since map access is not atomic. · dc5cffbe
    David Symonds authored
    Imagine your var has a value of zero. If you have a goroutine calling Set(5),
    and another calling Increment(+1), then you only want one of these outcomes:
      - Set completes first, and then Increment occurs => 6
      - Increment completes first, and then Set occurs => 5
    
    However, you could get a sequence:
      - read (for Increment) 0
      - set (for Set) 5
      - write (for Increment) 1
    This results in a value of 1, which is undesirable.
    
    Kudos to dnadasi for catching this.
    
    R=r
    APPROVED=r
    DELTA=3  (3 added, 0 deleted, 0 changed)
    OCL=27625
    CL=27625
    dc5cffbe
Name
Last commit
Last update
..
cmd Loading commit data...
lib Loading commit data...
lib9 Loading commit data...
libbio Loading commit data...
libmach_amd64 Loading commit data...
old/c Loading commit data...
pkg/debug/macho/testdata Loading commit data...
runtime Loading commit data...
Make.conf Loading commit data...
all.bash Loading commit data...
clean.bash Loading commit data...
make.bash Loading commit data...
quietgcc.bash Loading commit data...
run.bash Loading commit data...
sudo.bash Loading commit data...