flashmob преди 7 години
родител
ревизия
ef7478b42f
променени са 1 файла, в които са добавени 7 реда и са изтрити 0 реда
  1. 7 0
      backends/gateway.go

+ 7 - 0
backends/gateway.go

@@ -147,6 +147,13 @@ func (gw *BackendGateway) Process(e *mail.Envelope) Result {
 		return NewResult(response.Canned.SuccessMessageQueued + status.queuedID)
 	case <-time.After(gw.saveTimeout()):
 		Log().Error("Backend has timed out while saving email")
+		e.Lock() // lock the envelope - it's still processing here, we don't want the server to recycle it
+		go func() {
+			// keep waiting for the backend to finish processing
+			<-workerMsg.notifyMe
+			e.Unlock()
+			workerMsgPool.Put(workerMsg)
+		}()
 		return NewResult(response.Canned.FailBackendTimeout)
 	}
 }