Coder Social home page Coder Social logo

expressif / pecl-event-libevent Goto Github PK

View Code? Open in Web Editor NEW

This project forked from php/pecl-event-libevent

56.0 56.0 16.0 93 KB

PHP7 Libevent - event notification

Home Page: http://pecl.php.net/package/libevent

C 82.98% PHP 14.54% M4 2.47%

pecl-event-libevent's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pecl-event-libevent's Issues

_php_bufferevent_readcb segfult

Hi, I migrated pecl-libevent too for PHP7. But I met segfault at _php_bufferevent_readcb, and I can not solve this problems.

And, I found your patch, and test your code. But your code makes same problems too.

confirm follow codes plez.

thanks

test environment
CentOS 7.2
php-7.0.1
libevent-2.0.21-4.el7.x86_64 or libevent14-1.4.13-4.an3.x86_64

-- cut here--
Example #2 polling STDIN using buffered event API on http://php.net/manual/en/libevent.examples.php:

<?php

$socket = stream_socket_server ('tcp://0.0.0.0:2000', $errno, $errstr);
stream_set_blocking($socket, 0);
$base = event_base_new();
$event = event_new();
event_set($event, $socket, EV_READ | EV_PERSIST, 'ev_accept', $base);
event_base_set($event, $base);
event_add($event);
event_base_loop($base);

$GLOBALS['connections'] = array();
$GLOBALS['buffers'] = array();

function ev_accept($socket, $flag, $base) {
    static $id = 0;

    $connection = stream_socket_accept($socket);
    stream_set_blocking($connection, 0);

    $id += 1;

    $buffer = event_buffer_new($connection, 'ev_read', NULL, 'ev_error', $id);
    event_buffer_base_set($buffer, $base);
    event_buffer_timeout_set($buffer, 30, 30);
    event_buffer_watermark_set($buffer, EV_READ, 0, 0xffffff);
    event_buffer_priority_set($buffer, 10);
    event_buffer_enable($buffer, EV_READ | EV_PERSIST);

    // we need to save both buffer and connection outside
    $GLOBALS['connections'][$id] = $connection;
    $GLOBALS['buffers'][$id] = $buffer;
}

function ev_error($buffer, $error, $id) {
    event_buffer_disable($GLOBALS['buffers'][$id], EV_READ | EV_WRITE);
    event_buffer_free($GLOBALS['buffers'][$id]);
    fclose($GLOBALS['connections'][$id]);
    unset($GLOBALS['buffers'][$id], $GLOBALS['connections'][$id]);
}

function ev_read($buffer, $id) {
    while ($read = event_buffer_read($buffer, 256)) {
        var_dump($read);
    }
}
?>

Prepare a stable release

In order to release a stable version should have a way to ensure a 90% or more coverage of the code.

  • Find a tool to check code coverage on C
  • Unit test every function & every signature
  • Test memory leaks
  • Release the documentation

multi task request issue

Hello Guys
Please help me with on equestion
For example i have ws connection oppened and send:
ws.send('{id:1,"method":"login, .... ); - takes 10 seconds
ws.send('{id:2,method":"event_update_device_by_type_tree" ... '); -- takes 1 second

In this case i have such ordered response:
response {id: 1 ...},
response {id: 2 ...}

But i would have
response {id: 2 ...},
response {id: 1 ...}
Can anybode say how to do it using GenericSelect class
Or it is not possible to use this class for solving this issue?
Thanks

warn and notice during compile

This is compile output
Ubuntu 16.04

Configuring for:
PHP Api Version:         20151012
Zend Module Api No:      20151012
Zend Extension Api No:   320151012
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for PHP prefix... /usr
checking for PHP includes... -I/usr/include/php/20151012 -I/usr/include/php/20151012/main -I/usr/include/php/20151012/TSRM -I/usr/include/php/20151012/Zend -I/usr/include/php/20151012/ext -I/usr/include/php/20151012/ext/date/lib
checking for PHP extension directory... /usr/lib/php/20151012
checking for PHP installed headers prefix... /usr/include/php/20151012
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... no
checking for nawk... nawk
checking if nawk is broken... no
checking for libevent support... yes, shared
checking for libevent headers in default path... found in /usr
checking for event_base_new in -levent... yes
checking how to print strings... printf
checking for a sed that does not truncate output... (cached) /bin/sed
checking for fgrep... /bin/grep -F
checking for ld used by cc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking how to convert x86_64-pc-linux-gnu file names to x86_64-pc-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-pc-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking for gawk... (cached) nawk
checking command to parse /usr/bin/nm -B output from cc object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for mt... no
checking if : is a manifest tool... no
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if cc supports -fno-rtti -fno-exceptions... no
checking for cc option to produce PIC... -fPIC -DPIC
checking if cc PIC flag -fPIC -DPIC works... yes
checking if cc static flag -static works... yes
checking if cc supports -c -o file.o... yes
checking if cc supports -c -o file.o... (cached) yes
checking whether the cc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
configure: creating ./config.status
config.status: creating config.h
config.status: executing libtool commands
/bin/bash /tmp/phpext/pecl-event-libevent/libtool --mode=compile cc  -I. -I/tmp/phpext/pecl-event-libevent -DPHP_ATOM_INC -I/tmp/phpext/pecl-event-libevent/include -I/tmp/phpext/pecl-event-libevent/main -I/tmp/phpext/pecl-event-libevent -I/usr/include/php/20151012 -I/usr/include/php/20151012/main -I/usr/include/php/20151012/TSRM -I/usr/include/php/20151012/Zend -I/usr/include/php/20151012/ext -I/usr/include/php/20151012/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /tmp/phpext/pecl-event-libevent/libevent.c -o libevent.lo 
libtool: compile:  cc -I. -I/tmp/phpext/pecl-event-libevent -DPHP_ATOM_INC -I/tmp/phpext/pecl-event-libevent/include -I/tmp/phpext/pecl-event-libevent/main -I/tmp/phpext/pecl-event-libevent -I/usr/include/php/20151012 -I/usr/include/php/20151012/main -I/usr/include/php/20151012/TSRM -I/usr/include/php/20151012/Zend -I/usr/include/php/20151012/ext -I/usr/include/php/20151012/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /tmp/phpext/pecl-event-libevent/libevent.c  -fPIC -DPIC -o .libs/libevent.o
In file included from /usr/include/php/20151012/Zend/zend.h:31:0,
                 from /usr/include/php/20151012/main/php.h:36,
                 from /tmp/phpext/pecl-event-libevent/libevent.c:26:
/tmp/phpext/pecl-event-libevent/libevent.c: In function 'zif_event_set':
/usr/include/php/20151012/Zend/zend_types.h:551:25: warning: passing argument 2 of 'zend_hash_index_find' makes integer from pointer without a cast [-Wint-conversion]
 #define Z_RES(zval)     (zval).value.res
                         ^
/usr/include/php/20151012/Zend/zend_types.h:552:28: note: in expansion of macro 'Z_RES'
 #define Z_RES_P(zval_p)    Z_RES(*zval_p)
                            ^
/tmp/phpext/pecl-event-libevent/libevent.c:686:49: note: in expansion of macro 'Z_RES_P'
    fd = zend_hash_index_find(&EG(regular_list), Z_RES_P(fd));
                                                 ^
In file included from /usr/include/php/20151012/Zend/zend.h:36:0,
                 from /usr/include/php/20151012/main/php.h:36,
                 from /tmp/phpext/pecl-event-libevent/libevent.c:26:
/usr/include/php/20151012/Zend/zend_hash.h:156:30: note: expected 'zend_ulong {aka long unsigned int}' but argument is of type 'zend_resource * {aka struct _zend_resource *}'
 ZEND_API zval* ZEND_FASTCALL zend_hash_index_find(const HashTable *ht, zend_ulong h);
                              ^
In file included from /usr/include/php/20151012/Zend/zend.h:31:0,
                 from /usr/include/php/20151012/main/php.h:36,
                 from /tmp/phpext/pecl-event-libevent/libevent.c:26:
/tmp/phpext/pecl-event-libevent/libevent.c: In function 'zif_event_buffer_new':
/usr/include/php/20151012/Zend/zend_types.h:551:25: warning: passing argument 2 of 'zend_hash_index_find' makes integer from pointer without a cast [-Wint-conversion]
 #define Z_RES(zval)     (zval).value.res
                         ^
/usr/include/php/20151012/Zend/zend_types.h:552:28: note: in expansion of macro 'Z_RES'
 #define Z_RES_P(zval_p)    Z_RES(*zval_p)
                            ^
/tmp/phpext/pecl-event-libevent/libevent.c:925:49: note: in expansion of macro 'Z_RES_P'
   zfd = zend_hash_index_find(&EG(regular_list), Z_RES_P(zfd));
                                                 ^
In file included from /usr/include/php/20151012/Zend/zend.h:36:0,
                 from /usr/include/php/20151012/main/php.h:36,
                 from /tmp/phpext/pecl-event-libevent/libevent.c:26:
/usr/include/php/20151012/Zend/zend_hash.h:156:30: note: expected 'zend_ulong {aka long unsigned int}' but argument is of type 'zend_resource * {aka struct _zend_resource *}'
 ZEND_API zval* ZEND_FASTCALL zend_hash_index_find(const HashTable *ht, zend_ulong h);
                              ^
In file included from /usr/include/php/20151012/Zend/zend.h:31:0,
                 from /usr/include/php/20151012/main/php.h:36,
                 from /tmp/phpext/pecl-event-libevent/libevent.c:26:
/tmp/phpext/pecl-event-libevent/libevent.c: In function 'zif_event_buffer_fd_set':
/usr/include/php/20151012/Zend/zend_types.h:551:25: warning: passing argument 2 of 'zend_hash_index_find' makes integer from pointer without a cast [-Wint-conversion]
 #define Z_RES(zval)     (zval).value.res
                         ^
/usr/include/php/20151012/Zend/zend_types.h:552:28: note: in expansion of macro 'Z_RES'
 #define Z_RES_P(zval_p)    Z_RES(*zval_p)
                            ^
/tmp/phpext/pecl-event-libevent/libevent.c:1301:49: note: in expansion of macro 'Z_RES_P'
   zfd = zend_hash_index_find(&EG(regular_list), Z_RES_P(zfd));
                                                 ^
In file included from /usr/include/php/20151012/Zend/zend.h:36:0,
                 from /usr/include/php/20151012/main/php.h:36,
                 from /tmp/phpext/pecl-event-libevent/libevent.c:26:
/usr/include/php/20151012/Zend/zend_hash.h:156:30: note: expected 'zend_ulong {aka long unsigned int}' but argument is of type 'zend_resource * {aka struct _zend_resource *}'
 ZEND_API zval* ZEND_FASTCALL zend_hash_index_find(const HashTable *ht, zend_ulong h);
                              ^
/bin/bash /tmp/phpext/pecl-event-libevent/libtool --mode=link cc -DPHP_ATOM_INC -I/tmp/phpext/pecl-event-libevent/include -I/tmp/phpext/pecl-event-libevent/main -I/tmp/phpext/pecl-event-libevent -I/usr/include/php/20151012 -I/usr/include/php/20151012/main -I/usr/include/php/20151012/TSRM -I/usr/include/php/20151012/Zend -I/usr/include/php/20151012/ext -I/usr/include/php/20151012/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -o libevent.la -export-dynamic -avoid-version -prefer-pic -module -rpath /tmp/phpext/pecl-event-libevent/modules  libevent.lo -levent
libtool: link: cc -shared  -fPIC -DPIC  .libs/libevent.o   -levent  -g -O2   -Wl,-soname -Wl,libevent.so -o .libs/libevent.so
libtool: link: ( cd ".libs" && rm -f "libevent.la" && ln -s "../libevent.la" "libevent.la" )
/bin/bash /tmp/phpext/pecl-event-libevent/libtool --mode=install cp ./libevent.la /tmp/phpext/pecl-event-libevent/modules
libtool: install: cp ./.libs/libevent.so /tmp/phpext/pecl-event-libevent/modules/libevent.so
libtool: install: cp ./.libs/libevent.lai /tmp/phpext/pecl-event-libevent/modules/libevent.la
libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/depot_tools:/shaka_packager/src/out/Release:/sbin" ldconfig -n /tmp/phpext/pecl-event-libevent/modules
----------------------------------------------------------------------
Libraries have been installed in:
   /tmp/phpext/pecl-event-libevent/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the 'LD_RUN_PATH' environment variable
     during linking
   - use the '-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to '/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

Build complete.
Don't forget to run 'make test'.

Installing shared extensions:     /usr/lib/php/20151012/

[warn] sigaction: Invalid argument

Got this warning when trying to setup signal event, code sample:

$base = event_base_new();
$signalEvent = event_new();
event_set($signalEvent, SIGUSR1, EV_SIGNAL | EV_PERSIST, function () {
    echo 'Got signal'. PHP_EOL;
});
event_base_set($signalEvent, $base);
event_add($signalEvent);
event_base_loop($base);

Try it in Docker containers php7.0 and php7.0-zts, both based on Debian Jessie.

how to install on windows

Hello
Can you help me please to make php_libevent.dll for php 7 (as i understand i need to make dll from source files located here http://libevent.org/ latest version 2.0.22 ).
Put php_libevent.dll into ext folder
And what should i do futher?

_php_event_dtor makes segfault

Hi, reports bug again.

OS: Centos 7.2
PHP: php-7.0.1

code:

<?php
$base = event_base_new ();
$e = event_new();
?>

expected: no result
result: segfault

[root@an3 libevent]$ gdb php
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-80.el7
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/bin/php...(no debugging symbols found)...done.
(gdb) run a.php
Starting program: /bin/php a.php
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x0000000000739540 in zend_list_delete ()
Missing separate debuginfos, use: debuginfo-install php-cli-7.0.1-1.an3.x86_64
(gdb) bt
#0  0x0000000000739540 in zend_list_delete ()
#1  0x00007fffeb0d1b4d in _php_event_dtor (res=0x7fffffffcc50) at /root/rpmbuild/SOURCES/z/ext/libevent/libevent.c:174
#2  0x0000000000739341 in zend_resource_dtor ()
#3  0x00000000007393ca in list_entry_destructor ()
#4  0x0000000000735853 in zend_hash_index_del ()
#5  0x0000000000736733 in zend_hash_graceful_reverse_destroy ()
#6  0x0000000000715303 in shutdown_executor ()
#7  0x00000000007241da in zend_deactivate ()
#8  0x00000000006c3a31 in php_request_shutdown ()
#9  0x00000000007ab2c8 in do_cli ()
#10 0x0000000000440dcf in main ()
(gdb) f 1
#1  0x00007fffeb0d1b4d in _php_event_dtor (res=0x7fffffffcc50) at /root/rpmbuild/SOURCES/z/ext/libevent/libevent.c:174
174                     zend_list_delete(Z_RES_P(&event->stream_id));
(gdb) list
169             if (event->base) {
170                     base_id = event->base->rsrc_id;
171                     --event->base->events;
172             }
173             if (Z_TYPE_P(&event->stream_id) != IS_NULL) {
174                     zend_list_delete(Z_RES_P(&event->stream_id));
175             }
176             event_del(event->event);
177
178             _php_event_callback_free(event->callback);
(gdb)

Segmentation fault where there is more than one timer event

Hello,

Here is a code causing a Segmentation fault under following conditions:

  • PHP:
    (PHP 7.0.4 (cli) (built: Sep 24 2017 14:19:42) ( ZTS )
    Copyright (c) 1997-2016 The PHP Group
    Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies)

  • downloaded from today's master branch

  • added and compiled to PHP

  • run from CLI

Code:

`<?

require('./test.php');
require('./test2.php');

$event_arr = array();
$event_base = event_base_new();

$event_arr[] = array('e' => event_new(), '1' => 1, '2' => 2, '3' => 3, '4' => 4, '5' => 5);
event_timer_set($event_arr[0]['e'], function() { echo("cb1\n"); });
event_base_set($event_arr[0]['e'], $event_base);
event_add($event_arr[0]['e'], 1 * 1000000);

$event_arr[] = array('e' => event_new(), '1' => 1, '2' => 2, '3' => 3, '4' => 4, '5' => 5);
event_timer_set($event_arr[1]['e'], function() { echo("cb2\n"); });
event_base_set($event_arr[1]['e'], $event_base);
event_add($event_arr[1]['e'], 3 * 1000000);

while (true)
{
if (event_base_loop($event_base) === 1)
break;
}

?>
`
test.php and test2.php can be both empty (zero size). If you omit one of "require" commands it works. Also $event_arr must have 6 items. If you remove last item (index '5') it also works.

For me it seems like some weird "heap overflow" problem.

Thanks.

event_base_free problems

OS: Centos 7.2
PHP: 7.0.1
libevent: 1.4.3 or 2.0.21

The problems has 2 case. These cases has no problems under PHP 5.6.14 + mod_libevent-0.1.0.

_case 1_ codes:

<?php

function ec() { }

$sock = stream_socket_server ('tcp://0.0.0.0:2000', $errno, $errstr);
for ($i=0; $i<2; $i++) {
    $base = event_base_new();
    $ev = event_buffer_new($sock, NULL, NULL, 'ec');
    event_buffer_free($ev);
    event_base_free($base);
}
fclose ($sock);
?>

_expected:_ no result
_result:_ segfault

[root@an3 libevent]$ gdb php
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-80.el7
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/bin/php...(no debugging symbols found)...done.
(gdb) run z3.php
Starting program: /bin/php z3.php
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x00007fffeae9ba07 in event_base_free () from /lib64/libevent-2.0.so.5
Missing separate debuginfos, use: debuginfo-install php-cli-7.0.1-1.an3.x86_64
(gdb) bt 1
#0  0x00007fffeae9ba07 in event_base_free () from /lib64/libevent-2.0.so.5
(More stack frames follow...)
(gdb) bt
#0  0x00007fffeae9ba07 in event_base_free () from /lib64/libevent-2.0.so.5
#1  0x00007fffeb0d39fd in _php_event_base_dtor (res=<optimized out>) at /root/rpmbuild/SOURCES/z/ext/libevent/libevent.c:153
#2  0x0000000000739341 in zend_resource_dtor ()
#3  0x00000000007393ca in list_entry_destructor ()
#4  0x0000000000735853 in zend_hash_index_del ()
#5  0x000000000079ec28 in execute_ex ()
#6  0x00000000007aa507 in zend_execute ()
#7  0x0000000000724553 in zend_execute_scripts ()
#8  0x00000000006c40b8 in php_execute_script ()
#9  0x00000000007ac125 in do_cli ()
#10 0x0000000000440dcf in main ()
(gdb) f 1
#1  0x00007fffeb0d39fd in _php_event_base_dtor (res=<optimized out>) at /root/rpmbuild/SOURCES/z/ext/libevent/libevent.c:153
153             event_base_free(base->base);
(gdb) list
148
149     ZEND_RSRC_DTOR_FUNC(_php_event_base_dtor) /* {{{ */
150     {
151             php_event_base_t *base = (php_event_base_t*)res->ptr;
152
153             event_base_free(base->base);
154             efree(base);
155     }
156     /* }}} */
157
(gdb)

_case 2_ codes:

<?php

function ec() { }

for ($i=0; $i<2; $i++) {
    $sock = stream_socket_server ('tcp://0.0.0.0:2000', $errno, $errstr);
    $base = event_base_new();
    $ev = event_buffer_new($sock, NULL, NULL, 'ec');
    event_buffer_free($ev);
    event_base_free($base);
    fclose ($sock);
}
?>

_expected:_ no result
_result:_ $sock variable is modulated after calling the first event_base_free.

PHP Warning:  event_buffer_new(): fd argument must be valid PHP stream or socket resource or a file descriptor of type long in /root/rpmbuild/SOURCES/z/ext/libevent/z3.php on line 8

Warning: event_buffer_new(): fd argument must be valid PHP stream or socket resource or a file descriptor of type long in /root/rpmbuild/SOURCES/z/ext/libevent/z3.php on line 8
PHP Warning:  event_buffer_free() expects parameter 1 to be resource, boolean given in /root/rpmbuild/SOURCES/z/ext/libevent/z3.php on line 9

Warning: event_buffer_free() expects parameter 1 to be resource, boolean given in /root/rpmbuild/SOURCES/z/ext/libevent/z3.php on line 9
PHP Warning:  fclose(): supplied resource is not a valid stream resource in /root/rpmbuild/SOURCES/z/ext/libevent/z3.php on line 11

Warning: fclose(): supplied resource is not a valid stream resource in /root/rpmbuild/SOURCES/z/ext/libevent/z3.php on line 11

support voryx/Thruway with reactphp/event-loop's libevent backend

To make thruway[2] WAMPv2 router not crash starting and stopping event loop[3] I have to apply a patch[0]. The changes I made are based on php-ext-interbase[1] git.

Though, I do not know if this is the completely right way to fix. Any help is welcome.

[0] https://github.com/geki-yaba/gekis-playground/blob/master/dev-php/pecl-libevent/files/libevent.c.patch
[1] http://git.php.net/?p=php-src.git;a=blob_plain;f=ext/interbase/ibase_events.c;hb=HEAD
[2] https://github.com/voryx/Thruway
[3] https://github.com/reactphp/event-loop

libevent.c

Hi,

line 1272:

php_sock = (php_socket *)zend_fetch_resource_ex(zfd, NULL, php_sockets_le_socket())

by:

php_sock = (php_socket *)zend_fetch_resource_ex(zfd, NULL, php_sockets_le_socket());

Segmentation fault

Hi,

I have sometimes a segmentation fault. The crash file indicate that the problem happens in the function event_free with the function call zend_list_close(Z_RES_P(event->rsrc_id)).

Outdated?

I have PHP 7.0.8-3+deb.sury.org~trusty+1 (cli) ( NTS ) and keep getting this error:

PHP Warning: PHP Startup: libevent: Unable to initialize module
Module compiled with module API=20141001
PHP compiled with module API=20151012
These options need to match
in Unknown on line 0

I placed your files in my home dir and:

$ phpize
$ ./configure --with-php-config=/usr/bin/php-config7.0
$ make
make install

Am I doing something wrong?

Segmentation fault: 11 error

I got an error Segmentation fault: 11

run with code :

$base = event_base_new();
$event = event_new();

event_set($event, 0, EV_TIMEOUT, function() {
echo "function called";
});
event_base_set($event, $base);

event_add($event, 5000000);
event_base_loop($base);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.