php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59232 event_buffer + fopen
Submitted: 2010-05-26 10:16 UTC Modified: 2010-05-26 10:35 UTC
From: kak dot serpom dot po dot yaitsam at gmail dot com Assigned:
Status: Not a bug Package: libevent (PECL)
PHP Version: 5.3.2 OS: Fedora 13
Private report: No CVE-ID: None
 [2010-05-26 10:16 UTC] kak dot serpom dot po dot yaitsam at gmail dot com
Description:
------------
event_buffer_enable returns false when I use fopen. But it 
works normal when I use popen() or fsockopen().

Reproduce code:
---------------
<?php
function print_line($buf, $arg) {echo event_buffer_read($buf, 4096);}
function error_func($buf, $what, $arg) {}
$base = event_base_new();
$fp = fopen(__FILE__,'r');
$eb = event_buffer_new($fp, "print_line", NULL, "error_func", $base);
$set = event_buffer_base_set($eb, $base);
$enabled = event_buffer_enable($eb, EV_READ);
var_dump(array(
 'fp' => $fp,
 'eb' => $eb,
 'set' => $set,
 'enabled' => $enabled)
);
event_base_loop($base);


Expected result:
----------------
array(4) {
  ["fp"]=>
  resource(6) of type (stream)
  ["eb"]=>
  resource(7) of type (buffer event)
  ["set"]=>
  bool(true)
  ["enabled"]=>
  bool(true)
}
// source code bellow


Actual result:
--------------
array(4) {
  ["fp"]=>
  resource(6) of type (stream)
  ["eb"]=>
  resource(7) of type (buffer event)
  ["set"]=>
  bool(true)
  ["enabled"]=>
  bool(false)
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-05-26 10:35 UTC] tony at daylessday dot org
Yep, that's expected.
PHP returns false because libevent returns -1, which happens because epoll_ctl() returns -1 and sets errno to EPERM, which in this case means that this file descriptor doesn't support epoll.
See here: http://linux.die.net/man/2/epoll_ctl
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 18:01:25 2019 UTC