Skip to content

Commit ca3e57c

Browse files
committed
Merge branch 'true-async-api' into true-async-api-stable
2 parents 2a15657 + 7e9e31a commit ca3e57c

13 files changed

+2419
-4
lines changed

.circleci/config-true-async.yml

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
version: 2.1
2+
3+
jobs:
4+
arm:
5+
resource_class: arm.medium
6+
docker:
7+
- image: cimg/base:current-22.04
8+
- image: mysql:8.3
9+
environment:
10+
MYSQL_ALLOW_EMPTY_PASSWORD: true
11+
MYSQL_ROOT_PASSWORD: ''
12+
MYSQL_DATABASE: test
13+
- image: postgres:16
14+
environment:
15+
POSTGRES_PASSWORD: postgres
16+
POSTGRES_DB: test
17+
environment:
18+
LANGUAGE: ''
19+
LANG: en_US.UTF-8
20+
MYSQL_TEST_HOST: '127.0.0.1'
21+
MYSQL_TEST_PASSWD: ''
22+
MYSQL_TEST_USER: root
23+
PDO_MYSQL_TEST_DSN: 'mysql:host=127.0.0.1;dbname=test'
24+
PDO_MYSQL_TEST_PASS: ''
25+
PDO_MYSQL_TEST_USER: root
26+
PDO_PGSQL_TEST_DSN: 'pgsql:host=127.0.0.1 port=5432 dbname=test user=postgres password=postgres'
27+
steps:
28+
- checkout
29+
- run:
30+
name: Install system dependencies (including true async + libuv)
31+
command: |
32+
export DEBIAN_FRONTEND=noninteractive
33+
sudo apt-get update -y
34+
sudo apt-get install -y \
35+
gcc \
36+
g++ \
37+
autoconf \
38+
bison \
39+
re2c \
40+
locales \
41+
locales-all \
42+
ldap-utils \
43+
openssl \
44+
slapd \
45+
libgmp-dev \
46+
libicu-dev \
47+
libtidy-dev \
48+
libenchant-2-dev \
49+
libsasl2-dev \
50+
libxpm-dev \
51+
libzip-dev \
52+
libbz2-dev \
53+
libsqlite3-dev \
54+
libwebp-dev \
55+
libonig-dev \
56+
libcurl4-openssl-dev \
57+
libxml2-dev \
58+
libxslt1-dev \
59+
libpq-dev \
60+
libreadline-dev \
61+
libldap2-dev \
62+
libsodium-dev \
63+
libargon2-0-dev \
64+
libmm-dev \
65+
libsnmp-dev \
66+
snmpd \
67+
freetds-dev \
68+
dovecot-core \
69+
dovecot-pop3d \
70+
dovecot-imapd \
71+
sendmail \
72+
firebird-dev \
73+
liblmdb-dev \
74+
libtokyocabinet-dev \
75+
libdb-dev \
76+
libqdbm-dev \
77+
libjpeg-dev \
78+
libpng-dev \
79+
libfreetype6-dev \
80+
libuv1-dev
81+
- run:
82+
name: Download php-async (main) into ext/
83+
command: |
84+
git clone --depth=1 --branch=main https://github.com/true-async/php-async /tmp/php-async
85+
cp -r /tmp/php-async/* ./ext/
86+
- run:
87+
name: ./configure
88+
command: |
89+
./buildconf -f
90+
./configure \
91+
--enable-debug \
92+
--enable-zts \
93+
--enable-option-checking=fatal \
94+
--prefix=/usr \
95+
--enable-phpdbg \
96+
--enable-fpm \
97+
--enable-opcache \
98+
--with-pdo-mysql=mysqlnd \
99+
--with-mysqli=mysqlnd \
100+
--with-pgsql \
101+
--with-pdo-pgsql \
102+
--with-pdo-sqlite \
103+
--enable-intl \
104+
--without-pear \
105+
--enable-gd \
106+
--with-jpeg \
107+
--with-webp \
108+
--with-freetype \
109+
--with-xpm \
110+
--enable-exif \
111+
--with-zip \
112+
--with-zlib \
113+
--enable-soap \
114+
--enable-xmlreader \
115+
--with-xsl \
116+
--with-tidy \
117+
--enable-sysvsem \
118+
--enable-sysvshm \
119+
--enable-shmop \
120+
--enable-pcntl \
121+
--with-readline \
122+
--enable-mbstring \
123+
--with-curl \
124+
--with-gettext \
125+
--enable-sockets \
126+
--with-bz2 \
127+
--with-openssl \
128+
--with-gmp \
129+
--enable-bcmath \
130+
--enable-calendar \
131+
--enable-ftp \
132+
--with-enchant=/usr \
133+
--enable-sysvmsg \
134+
--with-ffi \
135+
--enable-zend-test \
136+
--enable-dl-test=shared \
137+
--with-ldap \
138+
--with-ldap-sasl \
139+
--with-password-argon2 \
140+
--with-mhash \
141+
--with-sodium \
142+
--enable-dba \
143+
--with-cdb \
144+
--enable-flatfile \
145+
--enable-inifile \
146+
--with-tcadb \
147+
--with-lmdb \
148+
--with-qdbm \
149+
--with-snmp \
150+
--with-config-file-path=/etc \
151+
--with-config-file-scan-dir=/etc/php.d \
152+
--with-pdo-firebird \
153+
--enable-experimental-async-api \ # <-- PHP true async API support
154+
--enable-async \ # <-- PHP true async extension
155+
--disable-phpdbg
156+
- run:
157+
name: make
158+
no_output_timeout: 30m
159+
command: make -j2 > /dev/null
160+
- run:
161+
name: make install
162+
command: |
163+
sudo make install
164+
sudo mkdir -p /etc/php.d
165+
sudo chmod 777 /etc/php.d
166+
echo opcache.enable_cli=1 > /etc/php.d/opcache.ini
167+
echo opcache.protect_memory=1 >> /etc/php.d/opcache.ini
168+
- run:
169+
name: Test
170+
no_output_timeout: 30m
171+
command: |
172+
sapi/cli/php run-tests.php \
173+
-d zend_extension=opcache.so \
174+
-d opcache.enable_cli=1 \
175+
-d opcache.jit_buffer_size=64M \
176+
-d opcache.jit=tracing \
177+
-d zend_test.observer.enabled=1 \
178+
-d zend_test.observer.show_output=0 \
179+
-P -q -x -j2 \
180+
-g FAIL,BORK,LEAK,XLEAK \
181+
--no-progress \
182+
--offline \
183+
--show-diff \
184+
--show-slow 1000 \
185+
--set-timeout 120 \
186+
--repeat 2
187+
188+
workflows:
189+
push-workflow:
190+
jobs:
191+
- arm

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,3 +309,8 @@ tmp-php.ini
309309
!/ext/lexbor/patches/*.patch
310310
!/ext/pcre/pcre2lib/config.h
311311
!/win32/build/Makefile
312+
313+
# ------------------------------------------------------------------------------
314+
# True Asynchronous extensions
315+
# ------------------------------------------------------------------------------
316+
/ext/async

Zend/zend.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
#include "Optimizer/zend_optimizer.h"
4242
#include "php.h"
4343
#include "php_globals.h"
44+
#ifdef PHP_ASYNC_API
45+
#include "zend_async_API.h"
46+
#endif
4447

4548
// FIXME: Breaks the declaration of the function below
4649
#undef zenderror
@@ -1946,9 +1949,18 @@ ZEND_API zend_result zend_execute_script(int type, zval *retval, zend_file_handl
19461949
if (Z_TYPE(EG(user_exception_handler)) != IS_UNDEF) {
19471950
zend_user_exception_handler();
19481951
}
1952+
#ifdef PHP_ASYNC_API
1953+
// If we are inside a coroutine,
1954+
// we do not call the final error handler,
1955+
// as the exception will be handled higher up in the method ZEND_ASYNC_RUN_SCHEDULER_AFTER_MAIN
1956+
if (false == ZEND_ASYNC_CURRENT_COROUTINE && EG(exception)) {
1957+
ret = zend_exception_error(EG(exception), E_ERROR);
1958+
}
1959+
#else
19491960
if (EG(exception)) {
19501961
ret = zend_exception_error(EG(exception), E_ERROR);
19511962
}
1963+
#endif
19521964
}
19531965
zend_destroy_static_vars(op_array);
19541966
destroy_op_array(op_array);

0 commit comments

Comments
 (0)