xftp: fix permanent error reported as temporary from http client - logs

This commit is contained in:
spaced4ndy
2023-04-21 21:07:38 +04:00
parent 4da637a565
commit 7079c70484
2 changed files with 12 additions and 6 deletions
+3
View File
@@ -390,6 +390,8 @@ runXFTPSndPrepareWorker c doWork = do
else pure sndFile
maxRecipients <- asks (xftpMaxRecipientsPerRequest . config)
let numRecipients' = min numRecipients maxRecipients
liftIO $ print "finished encrypting"
threadDelay 30000000
-- concurrently?
forM_ (filter (not . chunkCreated) chunks) $ createChunk numRecipients'
withStore' c $ \db -> updateSndFileStatus db sndFileId SFSUploading
@@ -463,6 +465,7 @@ runXFTPSndWorker c srv doWork = do
`catchError` \e -> retryOnError "XFTP snd worker" (retryLoop loop e delay') (retryDone e) e
where
retryLoop loop e replicaDelay = do
liftIO $ print $ "replica " <> show sndChunkReplicaId <> " temporary error"
flip catchError (\_ -> pure ()) $ do
notifyOnRetry <- asks (xftpNotifyErrsOnRetry . config)
when notifyOnRetry $ notify c sndFileEntityId $ SFERR e
@@ -108,16 +108,19 @@ getVerifiedHTTP2Client proxyUsername host port keyHash caStore config@HTTP2Clien
atomically $ do
writeTVar (connected c) True
putTMVar cVar (Right c')
process c' sendReq `E.finally` disconnected
process c' sendReq `E.finally` (putStrLn "process error" >> disconnected)
process :: HTTP2Client -> H.Client HTTP2Response
process HTTP2Client {client_ = HClient {reqQ}} sendReq = forever $ do
(req, respVar) <- atomically $ readTBQueue reqQ
sendReq req $ \r -> do
respBody <- getHTTP2Body r bodyHeadSize
let resp = HTTP2Response {response = r, respBody}
atomically $ putTMVar respVar resp
pure resp
do
( sendReq req $ \r -> do
respBody <- getHTTP2Body r bodyHeadSize
let resp = HTTP2Response {response = r, respBody}
atomically $ putTMVar respVar resp
pure resp
)
`E.finally` print "sendReq error"
-- | Disconnects client from the server and terminates client threads.
closeHTTP2Client :: HTTP2Client -> IO ()