Browse Source
Fix disconnecting client hangs. (#3)
During uncached file downloads the data is piped to two readers, one to
the requesting client, and one to a file system writer to store the new
file in the cache.
However, if the requesting client disconnects, the pipe stalls. This
results in the pipe that writes to the file system never completing, and
any subsequent requests for the file hang indefinitely waiting for the
in-progress download. This stays blocked until the entire process is
restarted.
Instead, use the readable-stream-clone module to clone two readable
streams, one for the client and one for the file system, so that they
are no longer dependent on each other.
Tested in various scenarios and confirmed to fix #2, which a number of
pkgbuild users were running into. It may also improve performance by
separating the pipe write speeds, allowing the file system writer to
return as quickly as possible and permit other clients to request the
newly cached file.