php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64696 Event::add(): Epoll ADD() on fd failed
Submitted: 2013-04-23 10:05 UTC Modified: 2013-07-16 19:17 UTC
From: andrey dot kalinovsky at gmail dot com Assigned: osmanov (profile)
Status: Closed Package: event (PECL)
PHP Version: 5.4.14 OS: Ubuntu 12.10 x64
Private report: No CVE-ID: None
 [2013-04-23 10:05 UTC] andrey dot kalinovsky at gmail dot com
Description:
------------
Event::add does not work on file descriptors obtained from fopen (or tmpfile). Bug 
seen on linux only, works perfectly fine on Mac OSX.



Test script:
---------------
<?php
 
$base = new EventBase();
 
$file = tmpfile();
 
$event = new Event($base, $file, Event::READ | Event::PERSIST, function()
                   {
                     echo "test";
                   });
$event->add();
$base->loop();

Expected result:
----------------
test

Actual result:
--------------
PHP Notice:  Event::add(): Epoll ADD(4) on fd 6 failed.  Old events were 0; read 
change was 0 (none); write change was 1 (add): Operation not permitted in 
/home/andrey/react/test.php on line 11
PHP Stack trace:
PHP   1. {main}() /home/andrey/react/test.php:0
PHP   2. Event->add() /home/andrey/react/test.php:11
PHP Warning:  Event::add(): Failed adding event in /home/andrey/react/test.php on 
line 11
PHP Stack trace:
PHP   1. {main}() /home/andrey/react/test.php:0
PHP   2. Event->add() /home/andrey/react/test.php:11

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-04-23 11:16 UTC] andrey dot kalinovsky at gmail dot com
Whoops, I haven't pasted the right version of the test script.

Here it is:


<?php

$base = new EventBase();

$file = tmpfile();

$event = new Event($base, $file, Event::WRITE, function()
                   {
                     echo "test";
                   });
$event->add();
$base->loop();
 [2013-07-16 19:17 UTC] osmanov@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: osmanov
 [2013-07-16 19:17 UTC] osmanov@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Sorry for the delay. I hadn't received E-mail notifications :-/

Probably, the output should be less cryptic. However, the reason of the error
messages is that "epoll" itself doesn't support regular files. Epoll expects
whether sockets, or pipes.

The code snippet you provided should work on OSX just fine, because Libevent
chooses different polling method there.

If you really want to watch events on a regular file, use EventConfig class
to avoid "epoll" method. Your code could look like the following:

<?php
$cfg = new EventConfig();
$cfg->avoidMethod("epoll");

$base = new EventBase($cfg);
$file = tmpfile();
$event = new Event($base, $file, Event::READ | Event::PERSIST, function() {
    echo "test";
});
$event->add();
$base->loop();

Thanks.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sun Mar 24 20:01:26 2019 UTC