better handling of content not available from cluster
Sending ERROR caused the client to get confused and protocol to freeze. Better to send empty DATA and indicate it's not valid. This fixes a hang in git-annex testremote of a cluster accessed via the http server. That testremote is still failing, for some reason after storing a test key, the cluster reports it as not present.
This commit is contained in:
parent
fbbedae497
commit
4304f1b6ae
1 changed files with 12 additions and 6 deletions
18
P2P/Proxy.hs
18
P2P/Proxy.hs
|
@ -276,10 +276,7 @@ proxyRequest proxydone proxyparams requestcomplete requestmessage protoerrhandle
|
||||||
handleGETTIMESTAMP remotesides
|
handleGETTIMESTAMP remotesides
|
||||||
GET _ _ k -> proxyGET (proxySelector proxyparams) k >>= \case
|
GET _ _ k -> proxyGET (proxySelector proxyparams) k >>= \case
|
||||||
Just remoteside -> handleGET remoteside requestmessage
|
Just remoteside -> handleGET remoteside requestmessage
|
||||||
Nothing ->
|
Nothing -> handleGETNoRemoteSide
|
||||||
protoerrhandler requestcomplete $
|
|
||||||
client $ net $ sendMessage $
|
|
||||||
ERROR "content not present"
|
|
||||||
PUT paf k -> do
|
PUT paf k -> do
|
||||||
af <- getassociatedfile paf
|
af <- getassociatedfile paf
|
||||||
remotesides <- proxyPUT (proxySelector proxyparams) af k
|
remotesides <- proxyPUT (proxySelector proxyparams) af k
|
||||||
|
@ -352,7 +349,7 @@ proxyRequest proxydone proxyparams requestcomplete requestmessage protoerrhandle
|
||||||
-- Read a message from one party, send it to the other,
|
-- Read a message from one party, send it to the other,
|
||||||
-- and then pass the message to the continuation.
|
-- and then pass the message to the continuation.
|
||||||
relayonemessage from to cont =
|
relayonemessage from to cont =
|
||||||
flip protoerrhandler (from $ net $ receiveMessage) $
|
flip protoerrhandler (from $ net receiveMessage) $
|
||||||
withresp $ \message ->
|
withresp $ \message ->
|
||||||
protoerrhandler (cont message) $
|
protoerrhandler (cont message) $
|
||||||
to $ net $ sendMessage message
|
to $ net $ sendMessage message
|
||||||
|
@ -461,6 +458,15 @@ proxyRequest proxydone proxyparams requestcomplete requestmessage protoerrhandle
|
||||||
(err:_) -> ERROR err
|
(err:_) -> ERROR err
|
||||||
else FAILURE_PLUS us
|
else FAILURE_PLUS us
|
||||||
|
|
||||||
|
-- Send an empty DATA and indicate it was invalid.
|
||||||
|
handleGETNoRemoteSide = protoerrhandler requestcomplete $
|
||||||
|
client $ net $ do
|
||||||
|
sendMessage $ DATA (Len 0)
|
||||||
|
sendBytes (Len 0) mempty nullMeterUpdate
|
||||||
|
when (proxyClientProtocolVersion proxyparams /= ProtocolVersion 0) $
|
||||||
|
sendMessage (VALIDITY Invalid)
|
||||||
|
void $ receiveMessage
|
||||||
|
|
||||||
handleGET remoteside message = getresponse (runRemoteSide remoteside) message $
|
handleGET remoteside message = getresponse (runRemoteSide remoteside) message $
|
||||||
withDATA (relayGET remoteside) $ \case
|
withDATA (relayGET remoteside) $ \case
|
||||||
ERROR err -> protoerrhandler requestcomplete $
|
ERROR err -> protoerrhandler requestcomplete $
|
||||||
|
@ -622,7 +628,7 @@ proxyRequest proxydone proxyparams requestcomplete requestmessage protoerrhandle
|
||||||
| proxyClientProtocolVersion proxyparams == ProtocolVersion 0 =
|
| proxyClientProtocolVersion proxyparams == ProtocolVersion 0 =
|
||||||
finish $ net receiveMessage
|
finish $ net receiveMessage
|
||||||
| otherwise =
|
| otherwise =
|
||||||
flip protoerrhandler (client $ net $ receiveMessage) $
|
flip protoerrhandler (client $ net receiveMessage) $
|
||||||
withresp $ \message ->
|
withresp $ \message ->
|
||||||
finish $ do
|
finish $ do
|
||||||
-- Relay VALID or INVALID message
|
-- Relay VALID or INVALID message
|
||||||
|
|
Loading…
Reference in a new issue