aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Joiner <anacrolix@gmail.com>2020-10-01 11:10:09 +1000
committerMatt Joiner <anacrolix@gmail.com>2020-10-01 11:10:09 +1000
commit6efb032b54bd38efa98e6d39021a765d9997857c (patch)
treee5d92bd55e331a0e5be85dd7121ea30ba872ce9e
parentTidy up newTx usage and recycle from WouldBlock (diff)
downloadstm-6efb032b54bd38efa98e6d39021a765d9997857c.tar.gz
stm-6efb032b54bd38efa98e6d39021a765d9997857c.tar.xz
New Tx must have completed=false
This uncovers a race condition where new Tx are already marked completed.
-rw-r--r--funcs.go1
-rw-r--r--tx.go2
2 files changed, 2 insertions, 1 deletions
diff --git a/funcs.go b/funcs.go
index b418cd7..91d6bc8 100644
--- a/funcs.go
+++ b/funcs.go
@@ -35,6 +35,7 @@ func init() {
func newTx() *Tx {
tx := txPool.Get().(*Tx)
tx.tries = 0
+ tx.completed = false
return tx
}
diff --git a/tx.go b/tx.go
index f613efb..065cb6c 100644
--- a/tx.go
+++ b/tx.go
@@ -125,7 +125,7 @@ func (tx *Tx) recycle() {
delete(tx.watching, v)
v.watchers.Delete(tx)
}
- txPool.Put(tx)
+ //txPool.Put(tx)
}
func (tx *Tx) lockAllVars() {