Closed Ekstazi closed 5 years ago
I think an infinite loop here is better, because it makes you aware of that coding error. Using an immediate watcher just hides the problem.
I don't think we can do anything here to improve the situation without breaking the interface. I think the best thing to do would be throwing an exception if read()
is called repeatedly and returned null
before.
https://github.com/amphp/byte-stream/blob/22113f2f14ae16928b8e8ade29b161d08f3031ba/lib/ResourceInputStream.php#L121
In some rare cases if caller code doesn't check for null this may cause infinite loop and amp loop will not work.
Need to use
immediateWatcher
instead. This may also affects output stream.Also see related ticket: https://github.com/amphp/ssh/issues/16