]> dgit.raspbian.org Git - git-annex.git/commitdiff
fix reversion in GET from proxy over http
authorJoey Hess <joeyh@joeyh.name>
Mon, 29 Jul 2024 15:03:18 +0000 (11:03 -0400)
committerJoey Hess <joeyh@joeyh.name>
Mon, 29 Jul 2024 15:07:09 +0000 (11:07 -0400)
4f3ae966662c38080fcafb9d5bbee4dedce566b8 caused a hang in GET,
which git-annex testremote could reliably cause.

The problem is that closing both P2P handles before waiting on the
asyncworker prevents all the DATA from getting sent.

The solution is to only close the P2P handles early when the
P2PConnection is being closed. When it's being released, let the
asyncworker finish. closeP2PConnection is called in GET when it was
unable to send all data, and in PUT when it did not receive all the
data, and in both cases closing the P2P handles early is ok.

P2P/Http/State.hs

index f52614b6c8109d4ba14411a476ba362ba23a93a1..7e43df81deeb14ef7873eafe2d6834fa1b1482dd 100644 (file)
@@ -378,12 +378,18 @@ proxyConnection proxyconnectionpoolsize relv connparams workerpool proxypool pro
                                liftIO $ runNetProto proxyfromclientrunst proxyfromclientconn $
                                        P2P.net P2P.receiveMessage
        
-       let releaseconn returntopool = do
+       let closebothsides = do
+               liftIO $ closeConnection proxyfromclientconn
+               liftIO $ closeConnection clientconn
+
+       let releaseconn connstillusable = do
                atomically $ void $ tryPutTMVar relv $ do
-                       liftIO $ closeConnection proxyfromclientconn
-                       liftIO $ closeConnection clientconn
+                       unless connstillusable
+                               closebothsides
                        r <- liftIO $ wait asyncworker
-                       if returntopool
+                       when connstillusable
+                               closebothsides
+                       if connstillusable
                                then liftIO $ do
                                        now <- getPOSIXTime
                                        evicted <- atomically $ putProxyConnectionPool proxypool proxyconnectionpoolsize connparams $