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

Check if input context completed

mirokuratczyk 5 лет назад
Родитель
Сommit
7f0d7c50bd
1 измененных файлов с 4 добавлено и 2 удалено
  1. 4 2
      psiphon/feedback.go

+ 4 - 2
psiphon/feedback.go

@@ -194,8 +194,10 @@ func SendFeedback(ctx context.Context, configJson, diagnosticsJson, uploadPath s
 		err = uploadFeedback(client, request)
 		cancelFunc()
 		if err != nil {
-			if stdlibErrors.Is(err, context.Canceled) {
-				return errors.TraceMsg(err, "feedback upload interrupted")
+			if ctx.Err() != nil {
+				// Input context has completed
+				return errors.TraceMsg(err,
+					fmt.Sprintf("feedback upload attempt %d cancelled", i+1))
 			}
 			// Do not sleep after the last attempt
 			if i+1 < feedbackUploadMaxRetries {