-
-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LibEventLoop and large messages #26
Comments
Related to reactphp/reactphp#240. Replacing |
I think this behavior is happening because of php stream buffers. What is happening is that the fread in Stream is using the default buffering in PHP (which appears to be 8k in my version). So PHP actually reads all of the 4097 bytes into the stream buffer and returns 4096 because that is the max we said we wanted, figuring it will give that last byte to us next time. This prevents event_loop from seeing anything available to read (because at that level, there isn't) and hangs there until the next read event. This can be fixed by telling PHP not to buffer: stream_set_read_buffer($sockB, 0); Here is why it doesn't do this with stream_select: https://github.com/php/php-src/blob/f3dde29394831c59fc927bd5e7a7800a3fbe8519/ext/standard/streamsfuncs.c#L791 |
Awesome, thanks for spotting and proving a simple test case to reproduce this! 👍 Afaict this is a serious issue in (only) the stream component (see reactphp/stream#20) and there's little we need to do about this in the event-loop component. |
This is fixed in reactphp/stream#20 |
I ran into an issue when sending messages that are larger than the
bufferSize
inStream
(4096).It appears that if the size of the data in the underlying stream is larger than the buffer,
handleData
only gets called once. The data remains there until there is another read event triggered on the stream.I wrote something to reproduce it:
With
StreamSelectLoop
, I get the results I expect:With
LibEventLoop
:And then it hangs.
I have run this test with the same results on Mac OS 10.10.2 with php 5.6.5 and also on Centos 6.5 with 5.5.20.
The text was updated successfully, but these errors were encountered: