XSendfile and encryption don't work together

This also contains fixes i noticed when looking at #5788. The main one is 32de3ecda131d51b590398a9feb85ab10d4f90ab 

@karlitschek @kabum @DeepDiver1975 @mend0za