Skip to content

Commit 6efc283

Browse files
committed
% prepare code for zend_call_destructors
1 parent 2bfbd25 commit 6efc283

File tree

3 files changed

+16
-28
lines changed

3 files changed

+16
-28
lines changed

async.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -945,26 +945,14 @@ PHP_RINIT_FUNCTION(async) /* {{{ */
945945
return SUCCESS;
946946
} /* }}} */
947947

948-
PHP_RSHUTDOWN_FUNCTION(async) /* {{{ */
949-
{
950-
ZEND_ASYNC_REACTOR_SHUTDOWN();
951-
952-
circular_buffer_dtor(&ASYNC_G(microtasks));
953-
circular_buffer_dtor(&ASYNC_G(coroutine_queue));
954-
zend_hash_destroy(&ASYNC_G(coroutines));
955-
956-
//async_host_name_list_dtor();
957-
return SUCCESS;
958-
} /* }}} */
959-
960948
zend_module_entry async_module_entry = {
961949
STANDARD_MODULE_HEADER,
962950
PHP_ASYNC_NAME,
963951
ext_functions,
964952
PHP_MINIT(async),
965953
PHP_MSHUTDOWN(async),
966954
PHP_RINIT(async),
967-
PHP_RSHUTDOWN(async),
955+
NULL,
968956
PHP_MINFO(async),
969957
PHP_ASYNC_VERSION,
970958
PHP_MODULE_GLOBALS(async),

async_API.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,17 @@ static void graceful_shutdown(void)
201201
start_graceful_shutdown();
202202
}
203203

204+
static void engine_shutdown(void)
205+
{
206+
ZEND_ASYNC_REACTOR_SHUTDOWN();
207+
208+
circular_buffer_dtor(&ASYNC_G(microtasks));
209+
circular_buffer_dtor(&ASYNC_G(coroutine_queue));
210+
zend_hash_destroy(&ASYNC_G(coroutines));
211+
212+
//async_host_name_list_dtor();
213+
}
214+
204215
zend_array * get_coroutines(void)
205216
{
206217
return &ASYNC_G(coroutines);
@@ -891,6 +902,7 @@ void async_api_register(void)
891902
add_microtask,
892903
get_awaiting_info,
893904
async_get_class_ce,
894-
(zend_async_new_iterator_t)async_iterator_new
905+
(zend_async_new_iterator_t)async_iterator_new,
906+
engine_shutdown
895907
);
896908
}

exceptions.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -193,15 +193,8 @@ ZEND_API ZEND_COLD void async_composite_exception_add_exception(zend_object *com
193193
}
194194
}
195195

196-
static void exception_coroutine_finally_callback(
197-
zend_async_event_t *event,
198-
zend_async_event_callback_t *callback,
199-
void * result,
200-
zend_object *exception
201-
)
196+
static void exception_coroutine_dispose(zend_coroutine_t *coroutine)
202197
{
203-
zend_coroutine_t *coroutine = (zend_coroutine_t *) event;
204-
205198
if (coroutine->extended_data != NULL) {
206199
zend_object *exception_obj = coroutine->extended_data;
207200
coroutine->extended_data = NULL;
@@ -245,14 +238,9 @@ bool async_spawn_and_throw(zend_object *exception, zend_async_scope_t *scope, in
245238
return false;
246239
}
247240

248-
coroutine->event.add_callback(&coroutine->event, ZEND_ASYNC_EVENT_CALLBACK(exception_coroutine_finally_callback));
249-
if (UNEXPECTED(EG(exception))) {
250-
coroutine->event.dispose(&coroutine->event);
251-
return false;
252-
}
253-
254241
coroutine->internal_entry = exception_coroutine_entry;
255242
coroutine->extended_data = exception;
243+
coroutine->extended_dispose = exception_coroutine_dispose;
256244
GC_ADDREF(exception);
257245

258246
return true;

0 commit comments

Comments
 (0)