From e4d6c7b3adf25410c3dc302463bbd96bf59275bc Mon Sep 17 00:00:00 2001 From: Steve Rhoades Date: Wed, 20 Aug 2014 07:16:05 -0700 Subject: [PATCH 1/2] add config option to ExtEventLoop to support readable streams via FEATURE_FDS --- src/ExtEventLoop.php | 5 +++-- tests/ExtEventLoopTest.php | 36 ++++++++++++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/ExtEventLoop.php b/src/ExtEventLoop.php index 6df3fa71..40b860ae 100644 --- a/src/ExtEventLoop.php +++ b/src/ExtEventLoop.php @@ -4,6 +4,7 @@ use Event; use EventBase; +use EventConfig as EventBaseConfig; use React\EventLoop\Tick\FutureTickQueue; use React\EventLoop\Tick\NextTickQueue; use React\EventLoop\Timer\Timer; @@ -27,9 +28,9 @@ class ExtEventLoop implements LoopInterface private $writeListeners = []; private $running; - public function __construct() + public function __construct(EventBaseConfig $config = null) { - $this->eventBase = new EventBase(); + $this->eventBase = new EventBase($config); $this->nextTickQueue = new NextTickQueue($this); $this->futureTickQueue = new FutureTickQueue($this); $this->timerEvents = new SplObjectStorage(); diff --git a/tests/ExtEventLoopTest.php b/tests/ExtEventLoopTest.php index a9570b40..d2748cd9 100644 --- a/tests/ExtEventLoopTest.php +++ b/tests/ExtEventLoopTest.php @@ -6,7 +6,12 @@ class ExtEventLoopTest extends AbstractLoopTest { - public function createLoop() + public function setUp() + { + $this->loop = $this->createLoop(); + } + + public function createLoop($readStreamCompatible = false) { if ('Linux' === PHP_OS && !extension_loaded('posix')) { $this->markTestSkipped('libevent tests skipped on linux due to linux epoll issues.'); @@ -16,7 +21,13 @@ public function createLoop() $this->markTestSkipped('ext-event tests skipped because ext-event is not installed.'); } - return new ExtEventLoop(); + $cfg = null; + if($readStreamCompatible) { + $cfg = new \EventConfig(); + $cfg->requireFeatures(\EventConfig::FEATURE_FDS); + } + + return new ExtEventLoop($cfg); } public function createStream() @@ -56,4 +67,25 @@ public function writeToStream($stream, $content) fwrite($stream, $content); } + + /** + * @group epoll-readable-error + */ + public function testCanUseReadableStreamWithFeatureFds() + { + $this->loop = $this->createLoop(true); + + $input = fopen('php://temp/maxmemory:0', 'r+'); + + fwrite($input, 'x'); + ftruncate($input, 0); + + $this->loop->addReadStream($input, $this->expectCallableExactly(2)); + + $this->writeToStream($input, "foo\n"); + $this->loop->tick(); + + $this->writeToStream($input, "bar\n"); + $this->loop->tick(); + } } From 21eb89755b735c20c04c1b4d89031be5527b7c5e Mon Sep 17 00:00:00 2001 From: Steve Rhoades Date: Wed, 20 Aug 2014 07:17:35 -0700 Subject: [PATCH 2/2] no need to override setUp --- tests/ExtEventLoopTest.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/ExtEventLoopTest.php b/tests/ExtEventLoopTest.php index d2748cd9..93408ad9 100644 --- a/tests/ExtEventLoopTest.php +++ b/tests/ExtEventLoopTest.php @@ -6,11 +6,6 @@ class ExtEventLoopTest extends AbstractLoopTest { - public function setUp() - { - $this->loop = $this->createLoop(); - } - public function createLoop($readStreamCompatible = false) { if ('Linux' === PHP_OS && !extension_loaded('posix')) { pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy