Browse Source

lib/sync: Fix a race in unlocker logging (fixes #3884)

Other routines use atomics, hence even if we are under a lock, we should
too.

We might atomically store with
Not sure how it happens, but it's between lines

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3974
Audrius Butkevicius 8 năm trước cách đây
mục cha
commit
120e6eab2c
1 tập tin đã thay đổi với 1 bổ sung1 xóa
  1. 1 1
      lib/sync/sync.go

+ 1 - 1
lib/sync/sync.go

@@ -123,7 +123,7 @@ func (m *loggedRWMutex) Lock() {
 
 	atomic.StoreInt32(&m.logUnlockers, 1)
 	m.RWMutex.Lock()
-	m.logUnlockers = 0
+	atomic.StoreInt32(&m.logUnlockers, 0)
 
 	holder := getHolder()
 	m.holder.Store(holder)