aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlukechampine <luke.champine@gmail.com>2016-03-30 17:05:58 -0400
committerlukechampine <luke.champine@gmail.com>2016-03-30 17:05:58 -0400
commit4e017ef7a61c760e94d6bdeb6df5cb56a044adfc (patch)
treedce0d5101e5a7e973d0e786cf18e4dde773ddf56
parentchange Get/Set to AtomicGet/Set (diff)
downloadstm-4e017ef7a61c760e94d6bdeb6df5cb56a044adfc.tar.gz
stm-4e017ef7a61c760e94d6bdeb6df5cb56a044adfc.tar.xz
fix race condition in tx.Get
-rw-r--r--stm.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/stm.go b/stm.go
index fcd1f02..8934455 100644
--- a/stm.go
+++ b/stm.go
@@ -135,6 +135,8 @@ func (tx *Tx) Get(v *Var) interface{} {
return val
}
// Otherwise, record and return its current value.
+ globalLock.Lock()
+ defer globalLock.Unlock()
tx.reads[v] = v.val
return v.val
}