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

Don't delete broker sessions on application-level errors

Rod Hynes 1 год назад
Родитель
Сommit
8915c4575f
1 измененных файлов с 10 добавлено и 1 удалено
  1. 10 1
      psiphon/common/inproxy/session.go

+ 10 - 1
psiphon/common/inproxy/session.go

@@ -977,8 +977,10 @@ func (s *ResponderSessions) HandlePacket(
 		return nil, errors.Trace(err)
 	}
 
+	retainSession := false
+
 	defer func() {
-		if retErr != nil {
+		if retErr != nil && !retainSession {
 
 			// If an error is returned, the session has failed, so don't
 			// retain it in the cache as it could be more recently used than
@@ -1091,6 +1093,13 @@ func (s *ResponderSessions) HandlePacket(
 
 	response, err := requestHandler(initiatorID, request)
 	if err != nil {
+
+		// Don't delete the session if the application-level request handler
+		// returns an error, as there is no problem with the Noise session.
+		// Non-failure application-level errors can include cases like a
+		// fronting CDN aborting a request due to timeout misalignment.
+		retainSession = true
+
 		return nil, errors.Trace(err)
 	}