From f27305383c2b396fbc11651a411fc08f61c321e4 Mon Sep 17 00:00:00 2001 From: Florian Engelhardt Date: Wed, 19 Jun 2024 12:15:48 +0200 Subject: [PATCH] make `request_info` from SAPI globals accessible in threads --- src/runtime.c | 1 + src/runtime.h | 3 +++ src/scheduler.c | 1 + tests/base/070.phpt | 18 ++++++++++++++++++ 4 files changed, 23 insertions(+) create mode 100644 tests/base/070.phpt diff --git a/src/runtime.c b/src/runtime.c index 39b8868..f656d3b 100644 --- a/src/runtime.c +++ b/src/runtime.c @@ -128,6 +128,7 @@ zend_object* php_parallel_runtime_create(zend_class_entry *type) { php_parallel_scheduler_init(runtime); runtime->parent.server = SG(server_context); + runtime->parent.request_info = &SG(request_info); return &runtime->std; } diff --git a/src/runtime.h b/src/runtime.h index 28cf990..1f138ab 100644 --- a/src/runtime.h +++ b/src/runtime.h @@ -15,6 +15,8 @@ | Author: krakjoe | +----------------------------------------------------------------------+ */ +#include "SAPI.h" + #ifndef HAVE_PARALLEL_RUNTIME_H #define HAVE_PARALLEL_RUNTIME_H @@ -32,6 +34,7 @@ typedef struct _php_parallel_runtime_t { } child; struct { void *server; + sapi_request_info *request_info; } parent; zend_llist schedule; zend_object std; diff --git a/src/scheduler.c b/src/scheduler.c index b7bafa5..80ca084 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -83,6 +83,7 @@ static zend_always_inline php_parallel_runtime_t* php_parallel_scheduler_setup(p TSRMLS_CACHE_UPDATE(); SG(server_context) = runtime->parent.server; + SG(request_info) = *runtime->parent.request_info; runtime->child.interrupt = &EG(vm_interrupt); diff --git a/tests/base/070.phpt b/tests/base/070.phpt new file mode 100644 index 0000000..238fc76 --- /dev/null +++ b/tests/base/070.phpt @@ -0,0 +1,18 @@ +--TEST-- +SAPI globals +--SKIPIF-- + +--FILE-- + +--EXPECT-- +int(1) +int(1)