• 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
..
container Loading commit data...
fmt Loading commit data...
go Loading commit data...
hash Loading commit data...
http Loading commit data...
io Loading commit data...
json Loading commit data...
math Loading commit data...
net Loading commit data...
os Loading commit data...
reflect Loading commit data...
regexp Loading commit data...
strconv Loading commit data...
sync Loading commit data...
syscall Loading commit data...
tabwriter Loading commit data...
template Loading commit data...
time Loading commit data...
unicode Loading commit data...
Makefile Loading commit data...
bignum.go Loading commit data...
bignum_test.go Loading commit data...
bufio.go Loading commit data...
bufio_test.go Loading commit data...
exec.go Loading commit data...
exec_test.go Loading commit data...
exvar.go Loading commit data...
exvar_test.go Loading commit data...
flag.go Loading commit data...
flag_test.go Loading commit data...
log.go Loading commit data...
log_test.go Loading commit data...
malloc.go Loading commit data...
once.go Loading commit data...
once_test.go Loading commit data...
path.go Loading commit data...
path_test.go Loading commit data...
rand.go Loading commit data...
sort.go Loading commit data...
sort_test.go Loading commit data...
strings.go Loading commit data...
strings_test.go Loading commit data...
testing.go Loading commit data...
utf8.go Loading commit data...
utf8_test.go Loading commit data...
xml.go Loading commit data...