Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
4d735db
Add initial poll API
bukka Aug 15, 2025
a0d935d
Add poll mechanism build checks and fix build
bukka Aug 16, 2025
997ca6c
Fix port and select backend and improve config
bukka Aug 16, 2025
2b55ce2
poll: restructure and refactore error handling and other bits
bukka Aug 16, 2025
5c37bab
poll: use zend memory allocator
bukka Aug 16, 2025
6811f99
poll: split init from create
bukka Aug 16, 2025
16489ef
poll: use pefree instead of free everywhere
bukka Aug 16, 2025
bdeeb30
poll: declare PHPAPI
bukka Aug 16, 2025
9ce08cb
poll: fix kqueue build
bukka Aug 18, 2025
d2d8978
Add initial streams polling API
bukka Aug 19, 2025
4b7bd42
poll: add missing private constructor
bukka Aug 19, 2025
209ca2b
poll: add initial test
bukka Aug 19, 2025
c3fd060
poll: reorganize stubs so functions are added
bukka Aug 19, 2025
c567f5a
poll: do not dtor stream event property
bukka Aug 20, 2025
ca728dc
poll: split the basic test to multiple eparated scenarios
bukka Aug 20, 2025
ec3b3ba
poll: fix returned events
bukka Aug 20, 2025
6ea0819
poll: rewrite kevent to track changed events
bukka Aug 20, 2025
3e10295
poll: refactore kevent to get rid of long term batching
bukka Aug 20, 2025
76845bc
poll: add modify and write test
bukka Aug 20, 2025
5cbfc0f
poll: optimize and refactore all apis to better handle max_events
bukka Aug 21, 2025
5b1c6f4
poll: use common logic for fd tracking
bukka Aug 21, 2025
793b094
poll: use custom allocation macros that can fail on persistent
bukka Aug 21, 2025
39cb2c9
poll: add Windows build config changes
bukka Aug 21, 2025
d697f96
poll: support poll creation by backend name
bukka Aug 21, 2025
dffdc43
poll: clean up and update tests to allow backend selection
bukka Aug 21, 2025
826292b
poll: refactore, simplify and extend tests
bukka Aug 21, 2025
64ad95c
poll: fix kqueue removal logic
bukka Aug 22, 2025
d4f7164
poll: check stream map before deleting for better error
bukka Aug 22, 2025
9c08f0b
poll: extend and simplify tests
bukka Aug 22, 2025
b2cb122
poll: add suitable max events callback to get right number of events …
bukka Aug 22, 2025
c5822f9
poll: group kqueue events and correctly count max events
bukka Aug 22, 2025
51a0762
poll: make the kqueue one shot logic consistent with epoll
bukka Aug 22, 2025
ac4e94a
poll: refactore and simplify oneshot kqueue logic
bukka Aug 23, 2025
1dd2d53
poll: improve and extend error handling with some helpers
bukka Aug 23, 2025
7e8f685
poll: extend and clean up tests
bukka Aug 23, 2025
573f736
poll: rewrite tests to expect events in any order
bukka Aug 23, 2025
8a46cd2
poll: support backend specific events in event expectation
bukka Aug 23, 2025
38fb0cf
poll: extend and fix edge tests
bukka Aug 23, 2025
8b5a602
poll: refactore and optimize fd table
bukka Aug 23, 2025
6728e29
poll: refactore poll logic to use more optimally fd table
bukka Aug 23, 2025
5203f90
poll: remove incorrect edge triggering simulation
bukka Aug 23, 2025
709568f
poll: fix test reporting of unpexpected events when array present
bukka Aug 24, 2025
4545a3c
poll: fix, refactore and simplify poll backend
bukka Aug 24, 2025
3f690a1
Make poll always available
bukka Aug 24, 2025
f9cf30e
poll: remove select backend as it is broken and not needed
bukka Aug 24, 2025
8b2ebb4
poll: fix compilation issues
bukka Aug 24, 2025
ee01407
poll: use STREAM_POLL_WRITE|STREAM_POLL_HUP as default for HOP
bukka Aug 24, 2025
63a3af4
poll: use php_pollfd instead of struct pollfd
bukka Aug 24, 2025
1babc8a
poll: remove select backend constants and fix backend name test
bukka Aug 24, 2025
337c7ff
poll: add stream poll classes to reflection getClassName test
bukka Aug 24, 2025
95cb522
poll: update arginfo
bukka Aug 24, 2025
6979b80
poll: introduce php_poll_msleep for win compat
bukka Aug 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions build/php.m4
Original file line number Diff line number Diff line change
Expand Up @@ -1371,6 +1371,48 @@ int main(void) {
])
])

AC_DEFUN([PHP_POLL_MECHANISMS],
[
AC_MSG_CHECKING([for polling mechanisms])
poll_mechanisms=""

AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
#include <sys/epoll.h>
], [
int fd = epoll_create(1);
return fd;
])], [
AC_DEFINE([HAVE_EPOLL], [1], [Define if epoll is available])
poll_mechanisms="$poll_mechanisms epoll"
])

AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
#include <sys/event.h>
#include <sys/time.h>
], [
int kq = kqueue();
return kq;
])], [
AC_DEFINE([HAVE_KQUEUE], [1], [Define if kqueue is available])
poll_mechanisms="$poll_mechanisms kqueue"
])

AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
#include <port.h>
], [
int port = port_create();
return port;
])], [
AC_DEFINE([HAVE_EVENT_PORTS], [1], [Define if event ports are available])
poll_mechanisms="$poll_mechanisms eventport"
])

dnl Set poll mechanisms including poll that is always available
poll_mechanisms="$poll_mechanisms poll"

AC_MSG_RESULT([$poll_mechanisms])
])

dnl ----------------------------------------------------------------------------
dnl Library/function existence and build sanity checks.
dnl ----------------------------------------------------------------------------
Expand Down
11 changes: 11 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ AC_CHECK_HEADERS(m4_normalize([
])

PHP_FOPENCOOKIE
PHP_POLL_MECHANISMS
PHP_BROKEN_GETCWD
AS_VAR_IF([GCC], [yes], [PHP_BROKEN_GCC_STRLEN_OPT])

Expand Down Expand Up @@ -1677,6 +1678,16 @@ PHP_ADD_SOURCES_X([main],
[PHP_FASTCGI_OBJS],
[no])

PHP_ADD_SOURCES([main/poll], m4_normalize([
poll_backend_epoll.c
poll_backend_eventport.c
poll_backend_kqueue.c
poll_backend_poll.c
poll_core.c
poll_fd_table.c
]),
[-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1])

PHP_ADD_SOURCES([main/streams], m4_normalize([
cast.c
filter.c
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@ AssertionError
Directory
RoundingMode
StreamBucket
StreamPollContext
StreamPollEvent
StreamPollException
__PHP_Incomplete_Class
php_user_filter
1 change: 1 addition & 0 deletions ext/standard/basic_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ PHP_MINIT_FUNCTION(basic) /* {{{ */
BASIC_MINIT_SUBMODULE(browscap)
BASIC_MINIT_SUBMODULE(standard_filters)
BASIC_MINIT_SUBMODULE(user_filters)
BASIC_MINIT_SUBMODULE(stream_poll)
BASIC_MINIT_SUBMODULE(password)
BASIC_MINIT_SUBMODULE(image)
BASIC_MINIT_SUBMODULE(url)
Expand Down
1 change: 1 addition & 0 deletions ext/standard/basic_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ PHP_MINFO_FUNCTION(basic);

ZEND_API void php_get_highlight_struct(zend_syntax_highlighter_ini *syntax_highlighter_ini);

PHP_MINIT_FUNCTION(stream_poll);
PHP_MINIT_FUNCTION(user_filters);
PHP_RSHUTDOWN_FUNCTION(user_filters);
PHP_RSHUTDOWN_FUNCTION(browscap);
Expand Down
15 changes: 15 additions & 0 deletions ext/standard/basic_functions.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -3386,6 +3386,21 @@ function soundex(string $string): string {}

/* streamsfuncs.c */

function stream_poll_create(int|string $backend = STREAM_POLL_BACKEND_AUTO): StreamPollContext {}

/** @param resource $stream */
function stream_poll_add(StreamPollContext $poll_ctx, $stream, int $events, mixed $data = null): void {}

/** @param resource $stream */
function stream_poll_modify(StreamPollContext $poll_ctx, $stream, int $events, mixed $data = null): void {}

/** @param resource $stream */
function stream_poll_remove(StreamPollContext $poll_ctx, $stream): void {}

function stream_poll_wait(StreamPollContext $poll_ctx, int $timeout = -1, int $max_events = -1): array {}

function stream_poll_backend_name(StreamPollContext $poll_ctx): string {}

function stream_select(?array &$read, ?array &$write, ?array &$except, ?int $seconds, ?int $microseconds = null): int|false {}

/**
Expand Down
42 changes: 41 additions & 1 deletion ext/standard/basic_functions_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ext/standard/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ PHP_NEW_EXTENSION([standard], m4_normalize([
scanf.c
sha1.c
soundex.c
stream_poll.c
streamsfuncs.c
string.c
strnatcmp.c
Expand Down
3 changes: 2 additions & 1 deletion ext/standard/config.w32
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ EXTENSION("standard", "array.c base64.c basic_functions.c browscap.c \
url_scanner_ex.c ftp_fopen_wrapper.c http_fopen_wrapper.c \
php_fopen_wrapper.c credits.c css.c var_unserializer.c ftok.c sha1.c \
user_filters.c uuencode.c filters.c proc_open.c password.c \
streamsfuncs.c http.c flock_compat.c hrtime.c", false /* never shared */,
stream_poll.c streamsfuncs.c http.c flock_compat.c hrtime.c",
false /* never shared */,
'/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1');
ADD_SOURCES("ext/standard/libavifinfo", "avifinfo.c", "standard");
PHP_STANDARD = "yes";
Expand Down
Loading
Loading