git-annex/P2P
Joey Hess 0b053b9611
Fix a P2P protocol hang
When readContent got Nothing from prepSendAnnex, it did not run its
callback, and the callback is what sends the DATA reply.

sendContent checks with contentSize that the object file is present, but
that doesn't really guarantee that prepSendAnnex won't return Nothing.

So, it was possible for a P2P protocol GET to not receive a response,
and appear to hang. When what it's really doing is waiting for the next
protocol command.

This seems most likely to happen when the annex is in direct mode, and the
file being requested has been modified. It could also happen in an indirect
mode repository if genInodeCache somehow failed. Perhaps due to a race
with a drop of the content file.

Fixed by making readContent behave the way its spec said it should,
and run the callback with L.empty in this case.

Note that, it's finee for readContent to send any amount of data
to the callback, including L.empty. sendBytes deals with that
by making sure it sends exactly the specified number of bytes,
aborting the protocol if it's too short. So, when L.empty is sent,
the protocol will end up aborting.

This work is supported by the NIH-funded NICEMAN (ReproNim TR&D3) project.
2018-11-02 13:41:50 -04:00
..
Address.hs include tor-annex in hidden service directory names 2016-12-21 14:39:32 -04:00
Annex.hs Fix a P2P protocol hang 2018-11-02 13:41:50 -04:00
Auth.hs use P2P auth for git-remote-tor-annex 2016-11-30 15:26:55 -04:00
IO.hs simplify 2018-10-22 15:54:12 -04:00
Protocol.hs Fix a P2P protocol hang 2018-11-02 13:41:50 -04:00