Просмотр исходного кода

Explicitly check that burst is active

Rod Hynes 5 лет назад
Родитель
Сommit
68ed97b3c4
2 измененных файлов с 4 добавлено и 3 удалено
  1. 2 1
      psiphon/common/burst.go
  2. 2 2
      psiphon/common/burst_test.go

+ 2 - 1
psiphon/common/burst.go

@@ -252,7 +252,8 @@ func (conn *BurstMonitoredConn) updateBurst(
 
 	// Assumes the associated mutex is locked.
 
-	if operationEnd.Sub(currentBurst.startTime) > deadline {
+	if !currentBurst.isZero() &&
+		operationEnd.Sub(currentBurst.startTime) > deadline {
 		// Partial burst failed to reach the target, so discard it.
 		currentBurst.reset()
 	}

+ 2 - 2
psiphon/common/burst_test.go

@@ -176,8 +176,8 @@ func TestBurstMonitoredConn(t *testing.T) {
 			t.Errorf("missing expected metric type: %s (%T)", name, value)
 			continue
 		}
-		minAcceptable := int64(float64(expectedValue) * 0.95)
-		maxAcceptable := int64(float64(expectedValue) * 1.05)
+		minAcceptable := int64(float64(expectedValue) * 0.90)
+		maxAcceptable := int64(float64(expectedValue) * 1.10)
 		if valueInt64 < minAcceptable || valueInt64 > maxAcceptable {
 			t.Errorf("unexpected metric value: %s (%v <= %v <= %v)",
 				name, minAcceptable, valueInt64, maxAcceptable)