Skip to content

Example code not working with ExtEventLoop #34

Closed
@giggsey

Description

@giggsey

My original test case:

<?php
require __DIR__ . '/vendor/autoload.php';
$stdoutLogFile = 'test.log';
/*
This works fine - it's writing to my log file
*/
$loop = new \React\EventLoop\StreamSelectLoop();
/*
Nothing gets written to the log file
Also, when starting this up, I get a notice & warning:
PHP Notice:  Event::add(): Epoll ADD(1) on fd 9 failed.  Old events were 0; read change was 1 (add); write change was 0 (none): Operation not permitted in vendor/react/event-loop/ExtEventLoop.php on line 258
PHP Warning:  Event::add(): Failed adding event in vendor/react/event-loop/ExtEventLoop.php on line 258
My Actual script doesn't have this warning, as it pipes from a Process stdout to the Stream. It still has the same problem though (not writing to the file)
*/
$loop = new \React\EventLoop\ExtEventLoop();
$stdout = new React\Stream\Stream(fopen($stdoutLogFile, 'a'), $loop);
$stdout->on(
    'error',
    function ($error) {
        var_dump($error);
    }
);
$loop->addPeriodicTimer(
    1,
    function (React\EventLoop\Timer\TimerInterface $timer) use ($stdout) {
        $stdout->write('Starting...');
    }
);
$loop->run();

I tried the simplier demo code provided in README.md, and that didn't write either (same warnings generated).

Works fine when using 'StreamSelectLoop'.

Test System details:

  • CentOS 6.x
  • PHP 5.6.15 (Remi RPMs)

event phpinfo output

  • Event support => enabled
  • Sockets support => enabled
  • Debug support => disabled
  • Extra functionality support including HTTP, DNS, and RPC => enabled
  • OpenSSL support => enabled
  • Thread safety support => disabled
  • Extension version => 1.11.1
  • libevent2 headers version => 2.0.21-stable

Also tried it on a Vagrant box (scotch/box) by doing pecl install event

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions