Skip to content

Commit 7e7927c

Browse files
committed
Drop zend_fiber_cleanup
Using dtor_obj handler instead of free_obj fixed the issue this was attempting to handle.
1 parent 79abf31 commit 7e7927c

File tree

3 files changed

+17
-39
lines changed

3 files changed

+17
-39
lines changed

Zend/zend_fibers.c

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,7 @@ static void zend_fiber_object_destroy(zend_object *object)
397397
zend_object *exception = EG(exception);
398398
EG(exception) = NULL;
399399
fiber->status = ZEND_FIBER_STATUS_SHUTDOWN;
400+
GC_ADDREF(&fiber->std);
400401
zend_fiber_switch_to(fiber);
401402
EG(exception) = exception;
402403
}
@@ -409,23 +410,7 @@ static void zend_fiber_object_destroy(zend_object *object)
409410
zend_fiber_destroy_context(&fiber->context);
410411

411412
zend_object_std_dtor(&fiber->std);
412-
}
413-
414-
void zend_fiber_cleanup(void)
415-
{
416-
zend_fiber *fiber;
417-
zend_object *exception = EG(exception);
418-
EG(exception) = NULL;
419-
420-
ZEND_HASH_REVERSE_FOREACH_PTR(&EG(fibers), fiber) {
421-
if (fiber->status == ZEND_FIBER_STATUS_SUSPENDED) {
422-
fiber->status = ZEND_FIBER_STATUS_SHUTDOWN;
423-
GC_ADDREF(&fiber->std);
424-
zend_fiber_switch_to(fiber);
425-
}
426-
} ZEND_HASH_FOREACH_END();
427413

428-
EG(exception) = exception;
429414
}
430415

431416
ZEND_METHOD(Fiber, __construct)
@@ -708,7 +693,7 @@ void zend_register_fiber_ce(void)
708693
zend_ce_fiber->unserialize = zend_class_unserialize_deny;
709694

710695
zend_fiber_handlers = std_object_handlers;
711-
zend_fiber_handlers.free_obj = zend_fiber_object_destroy;
696+
zend_fiber_handlers.dtor_obj = zend_fiber_object_destroy;
712697
zend_fiber_handlers.clone_obj = NULL;
713698

714699
zend_ce_fiber_error = register_class_FiberError(zend_ce_error);

Zend/zend_fibers.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ BEGIN_EXTERN_C()
2727

2828
void zend_register_fiber_ce(void);
2929
void zend_fiber_init(void);
30-
void zend_fiber_cleanup(void);
3130
void zend_fiber_shutdown(void);
3231

3332
extern ZEND_API zend_class_entry *zend_ce_fiber;

main/main.c

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@
7373
#include "zend_dtrace.h"
7474
#include "zend_observer.h"
7575
#include "zend_system_id.h"
76-
#include "zend_fibers.h"
7776

7877
#include "php_content_types.h"
7978
#include "php_ticks.h"
@@ -1773,17 +1772,12 @@ void php_request_shutdown(void *dummy)
17731772
php_call_shutdown_functions();
17741773
}
17751774

1776-
/* 2. Cleanup all active fibers. */
1777-
zend_try {
1778-
zend_fiber_cleanup();
1779-
} zend_end_try();
1780-
1781-
/* 3. Call all possible __destruct() functions */
1775+
/* 2. Call all possible __destruct() functions */
17821776
zend_try {
17831777
zend_call_destructors();
17841778
} zend_end_try();
17851779

1786-
/* 4. Flush all output buffers */
1780+
/* 3. Flush all output buffers */
17871781
zend_try {
17881782
bool send_buffer = SG(request_info).headers_only ? 0 : 1;
17891783

@@ -1800,27 +1794,27 @@ void php_request_shutdown(void *dummy)
18001794
}
18011795
} zend_end_try();
18021796

1803-
/* 5. Reset max_execution_time (no longer executing php code after response sent) */
1797+
/* 4. Reset max_execution_time (no longer executing php code after response sent) */
18041798
zend_try {
18051799
zend_unset_timeout();
18061800
} zend_end_try();
18071801

1808-
/* 6. Call all extensions RSHUTDOWN functions */
1802+
/* 5. Call all extensions RSHUTDOWN functions */
18091803
if (PG(modules_activated)) {
18101804
zend_deactivate_modules();
18111805
}
18121806

1813-
/* 7. Shutdown output layer (send the set HTTP headers, cleanup output handlers, etc.) */
1807+
/* 6. Shutdown output layer (send the set HTTP headers, cleanup output handlers, etc.) */
18141808
zend_try {
18151809
php_output_deactivate();
18161810
} zend_end_try();
18171811

1818-
/* 8. Free shutdown functions */
1812+
/* 7. Free shutdown functions */
18191813
if (PG(modules_activated)) {
18201814
php_free_shutdown_functions();
18211815
}
18221816

1823-
/* 9. Destroy super-globals */
1817+
/* 8. Destroy super-globals */
18241818
zend_try {
18251819
int i;
18261820

@@ -1829,38 +1823,38 @@ void php_request_shutdown(void *dummy)
18291823
}
18301824
} zend_end_try();
18311825

1832-
/* 10. Shutdown scanner/executor/compiler and restore ini entries */
1826+
/* 9. Shutdown scanner/executor/compiler and restore ini entries */
18331827
zend_deactivate();
18341828

1835-
/* 11. free request-bound globals */
1829+
/* 10. free request-bound globals */
18361830
php_free_request_globals();
18371831

1838-
/* 12. Call all extensions post-RSHUTDOWN functions */
1832+
/* 11. Call all extensions post-RSHUTDOWN functions */
18391833
zend_try {
18401834
zend_post_deactivate_modules();
18411835
} zend_end_try();
18421836

1843-
/* 13. SAPI related shutdown (free stuff) */
1837+
/* 12. SAPI related shutdown (free stuff) */
18441838
zend_try {
18451839
sapi_deactivate();
18461840
} zend_end_try();
18471841

1848-
/* 14. free virtual CWD memory */
1842+
/* 13. free virtual CWD memory */
18491843
virtual_cwd_deactivate();
18501844

1851-
/* 15. Destroy stream hashes */
1845+
/* 14. Destroy stream hashes */
18521846
zend_try {
18531847
php_shutdown_stream_hashes();
18541848
} zend_end_try();
18551849

1856-
/* 16. Free Willy (here be crashes) */
1850+
/* 15. Free Willy (here be crashes) */
18571851
zend_arena_destroy(CG(arena));
18581852
zend_interned_strings_deactivate();
18591853
zend_try {
18601854
shutdown_memory_manager(CG(unclean_shutdown) || !report_memleaks, 0);
18611855
} zend_end_try();
18621856

1863-
/* 17. Deactivate Zend signals */
1857+
/* 16. Deactivate Zend signals */
18641858
#ifdef ZEND_SIGNALS
18651859
zend_signal_deactivate();
18661860
#endif

0 commit comments

Comments
 (0)