Skip to content
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

Enforce using non-blocking I/O #46

Merged
merged 3 commits into from
Mar 9, 2017
Merged

Enforce using non-blocking I/O #46

merged 3 commits into from
Mar 9, 2017

Conversation

clue
Copy link
Member

@clue clue commented Jul 6, 2016

Opening this an RFC, any input is welcome! 👍

Reading from a stream should never block the loop.
This is known to be an issue for process pipes on Windows.

Refs: reactphp/child-process#9 and reactphp/reactphp#68

@clue clue added this to the v0.5 milestone Aug 14, 2016
@clue
Copy link
Member Author

clue commented Nov 13, 2016

The following gist can be used to reproduce this issue:

$loop = React\EventLoop\Factory::create();

// dummy timer to see some activity on STDOUT
$loop->addPeriodicTimer(1.0, function () {
    echo microtime(true) . PHP_EOL;
});

// this will always return false on Windows
var_dump(stream_set_blocking(STDIN, false));

$loop->addReadStream(STDIN, function () {
    // this will always block on Windows
    fread(STDIN, 1024);
});

$loop->run();

See https://bugs.php.net/bug.php?id=47918 for details, there does not appear to be a way to circumvent this in PHP.

@clue clue added the BC break label Jan 18, 2017
@clue clue modified the milestones: v0.6.0, v0.5.0 Mar 3, 2017
clue added 2 commits March 8, 2017 10:23
Reading from a stream should *never* block the loop.
This is known to be an issue for process pipes on Windows.
@clue clue changed the title [RFC] Enforce using non-blocking I/O Enforce using non-blocking I/O Mar 8, 2017
@clue clue added the bug label Mar 8, 2017
@clue
Copy link
Member Author

clue commented Mar 8, 2017

Rebased on current master and added tests to ensure 100% coverage using a stream wrapper :shipit:

@jsor
Copy link
Member

jsor commented Mar 8, 2017

@clue Tests on hhvm are failing.

React\Tests\Stream\EnforceBlockingWrapper::stream_cast is not implemented!

@clue
Copy link
Member Author

clue commented Mar 9, 2017

Thanks for spotting, updated to fix tests on HHVM :shipit:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants