فهرست منبع

Explicitly check that burst is active

Rod Hynes 5 سال پیش
والد
کامیت
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.
 	// 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.
 		// Partial burst failed to reach the target, so discard it.
 		currentBurst.reset()
 		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)
 			t.Errorf("missing expected metric type: %s (%T)", name, value)
 			continue
 			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 {
 		if valueInt64 < minAcceptable || valueInt64 > maxAcceptable {
 			t.Errorf("unexpected metric value: %s (%v <= %v <= %v)",
 			t.Errorf("unexpected metric value: %s (%v <= %v <= %v)",
 				name, minAcceptable, valueInt64, maxAcceptable)
 				name, minAcceptable, valueInt64, maxAcceptable)