浏览代码

Fix: race condition accessing progressSLOKTime

Rod Hynes 9 年之前
父节点
当前提交
60332b5db7
共有 1 个文件被更改,包括 3 次插入3 次删除
  1. 3 3
      psiphon/common/osl/osl.go

+ 3 - 3
psiphon/common/osl/osl.go

@@ -187,8 +187,8 @@ type ClientSeedState struct {
 	propagationChannelID string
 	signalIssueSLOKs     chan struct{}
 	progress             []*TrafficValues
-	mutex                sync.Mutex
 	progressSLOKTime     int64
+	mutex                sync.Mutex
 	issuedSLOKs          map[string]*SLOK
 	payloadSLOKs         []*SLOK
 }
@@ -549,8 +549,8 @@ func (state *ClientSeedState) issueSLOKs() {
 
 	slokTime := getSLOKTime(state.scheme.SeedPeriodNanoseconds)
 
-	if slokTime != state.progressSLOKTime {
-		state.progressSLOKTime = slokTime
+	if slokTime != atomic.LoadInt64(&state.progressSLOKTime) {
+		atomic.StoreInt64(&state.progressSLOKTime, slokTime)
 		// The progress map structure is not reset or modifed; instead
 		// the mapped accumulator values are zeroed. Concurrently, port
 		// forward relay goroutines continue to add to these accumulators.