Premature closing of response was causing corruption transferring photos over slow connections
It's causing a lot of errors on closing the fd, even after I started checking the fd before destroying it. I suppose it's the underlying stream implementation trying to destroy() a stream twice. net:231 close(fd); ^ Error: EBADF, Bad file descriptor at closeFD (net:231:3) at Stream.destroy (net:999:17) at Stream.<anonymous> (http:731:12) at Stream.emit (events:42:20) at Timer.callback (net:151:19) at node.js:221:9 Will have to look at the Stream source code to see if I can find the problem. Till then, the file descriptors are automatically closed when the readStream reaches the end, so antinode shouldn't leak file descriptors.
- We moved to sendfile before node.JS had binary buffers. A read write loop is a lot faster now than back when node was converting everything to UTF-8 strings. Sendfile isn't needed. Sendfile(2) was causing all sorts of hassles - Connections would timeout, then sendfile would try and send out a null file descriptor - Sendfile(2) has crap error messages for when the shit hits the fan. 'bad argument'