haskell/hackage-server — pull request #185 by horus (2014-01-22 11:18:00+00:00)
Title: add strictness, fix "resource vanished" error

This patch fixes the following problem:

hackage-server$ dist/build/hackage-mirror/hackage-mirror -v mirror.cfg --continuous --keep-going
36303 packages to mirror.
mirroring AC-Angle-1.0
Warning: : hClose: resource vanished ($msg)
Abandoning this mirroring attempt.
Next try will be in 32 minutes, at 17:26 CST

$msg: "Broken pipe" on Linux, "Connection reset by peer" on FreeBSD.

I will write down more details soon if time permits.

Basically the browser module was browsing lazily and tried to re-use a connection marked as "Connection: closed" by the Happstack server it PUT to, since the FIN bit of the last segment of response was set, the PUT attempt failed with a RST.

This patch fixes the problem by using strict bytestring, and tested OK locally. Other file operations remain lazy.

P./S. To avoiding the 'prematurely closed' problem, a proxy such as nginx can also be used to maintain the connection, so the closed connection will be handled by the nginx side.