reactphp/stream — pull request #4 by DaveRandom (2014-06-11 16:38:46+00:00)
Title: Avoid potential race condition between close/drain events when piping

When piping data, it is possible that a stream may emit the `drain` event after the `close` event. This causes the stream to be watched for readable data that will never arrive and the handler will never be removed - causing the process to run forever when there is technically nothing left to do.

I found I could demonstrate this problem about 1/10 runs of the reactphp/react `parallel-download` example.

This patch addresses the problem by refusing to `resume()` if the stream is not marked as readable.