Skip to content

Commit 79abf31

Browse files
committed
Rename FiberExit to GracefulExit
1 parent 7dc3d4d commit 79abf31

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

Zend/zend_exceptions.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ ZEND_API zend_class_entry *zend_ce_arithmetic_error;
4343
ZEND_API zend_class_entry *zend_ce_division_by_zero_error;
4444
ZEND_API zend_class_entry *zend_ce_unhandled_match_error;
4545

46-
/* Internal pseudo-exception that is not exposed to userland. */
46+
/* Internal pseudo-exception that is not exposed to userland. Throwing this exception *does not* execute finally blocks. */
4747
static zend_class_entry zend_ce_unwind_exit;
4848

49-
/* Internal pseudo-exception used in destroyed fibers that is not exposed to userland. */
50-
static zend_class_entry zend_ce_fiber_exit;
49+
/* Internal pseudo-exception that is not exposed to userland. Throwing this exception *does* execute finally blocks. */
50+
static zend_class_entry zend_ce_graceful_exit;
5151

5252
ZEND_API void (*zend_throw_exception_hook)(zend_object *ex);
5353

@@ -97,7 +97,7 @@ void zend_exception_set_previous(zend_object *exception, zend_object *add_previo
9797
return;
9898
}
9999

100-
if (exception == add_previous || zend_is_unwind_exit(add_previous) || zend_is_fiber_exit(add_previous)) {
100+
if (exception == add_previous || zend_is_unwind_exit(add_previous) || zend_is_graceful_exit(add_previous)) {
101101
OBJ_RELEASE(add_previous);
102102
return;
103103
}
@@ -795,7 +795,7 @@ void zend_register_default_exception(void) /* {{{ */
795795

796796
INIT_CLASS_ENTRY(zend_ce_unwind_exit, "UnwindExit", NULL);
797797

798-
INIT_CLASS_ENTRY(zend_ce_fiber_exit, "FiberExit", NULL);
798+
INIT_CLASS_ENTRY(zend_ce_graceful_exit, "GracefulExit", NULL);
799799
}
800800
/* }}} */
801801

@@ -954,7 +954,7 @@ ZEND_API ZEND_COLD zend_result zend_exception_error(zend_object *ex, int severit
954954

955955
zend_string_release_ex(str, 0);
956956
zend_string_release_ex(file, 0);
957-
} else if (ce_exception == &zend_ce_unwind_exit) {
957+
} else if (ce_exception == &zend_ce_unwind_exit || ce_exception == &zend_ce_graceful_exit) {
958958
/* We successfully unwound, nothing more to do.
959959
* We still return FAILURE in this case, as further execution should still be aborted. */
960960
} else {
@@ -992,10 +992,10 @@ ZEND_API ZEND_COLD void zend_throw_unwind_exit(void)
992992
EG(current_execute_data)->opline = EG(exception_op);
993993
}
994994

995-
ZEND_API ZEND_COLD void zend_throw_fiber_exit(void)
995+
ZEND_API ZEND_COLD void zend_throw_graceful_exit(void)
996996
{
997997
ZEND_ASSERT(!EG(exception));
998-
EG(exception) = zend_objects_new(&zend_ce_fiber_exit);
998+
EG(exception) = zend_objects_new(&zend_ce_graceful_exit);
999999
EG(opline_before_exception) = EG(current_execute_data)->opline;
10001000
EG(current_execute_data)->opline = EG(exception_op);
10011001
}
@@ -1005,7 +1005,7 @@ ZEND_API bool zend_is_unwind_exit(const zend_object *ex)
10051005
return ex->ce == &zend_ce_unwind_exit;
10061006
}
10071007

1008-
ZEND_API bool zend_is_fiber_exit(const zend_object *ex)
1008+
ZEND_API bool zend_is_graceful_exit(const zend_object *ex)
10091009
{
1010-
return ex->ce == &zend_ce_fiber_exit;
1010+
return ex->ce == &zend_ce_graceful_exit;
10111011
}

Zend/zend_exceptions.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ extern ZEND_API void (*zend_throw_exception_hook)(zend_object *ex);
7070
ZEND_API ZEND_COLD zend_result zend_exception_error(zend_object *exception, int severity);
7171

7272
ZEND_API ZEND_COLD void zend_throw_unwind_exit(void);
73-
ZEND_API ZEND_COLD void zend_throw_fiber_exit(void);
73+
ZEND_API ZEND_COLD void zend_throw_graceful_exit(void);
7474
ZEND_API bool zend_is_unwind_exit(const zend_object *ex);
75-
ZEND_API bool zend_is_fiber_exit(const zend_object *ex);
75+
ZEND_API bool zend_is_graceful_exit(const zend_object *ex);
7676

7777
#include "zend_globals.h"
7878

Zend/zend_fibers.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ static void ZEND_STACK_ALIGNED zend_fiber_execute(zend_fiber_context *context)
351351

352352
if (EG(exception)) {
353353
if (fiber->status == ZEND_FIBER_STATUS_SHUTDOWN) {
354-
if (EXPECTED(zend_is_fiber_exit(EG(exception)))) {
354+
if (EXPECTED(zend_is_graceful_exit(EG(exception)) || zend_is_unwind_exit(EG(exception)))) {
355355
zend_clear_exception();
356356
} else {
357357
zend_exception_error(EG(exception), E_ERROR);
@@ -514,9 +514,11 @@ ZEND_METHOD(Fiber, suspend)
514514
if (fiber->status == ZEND_FIBER_STATUS_SHUTDOWN) {
515515
// This occurs when the fiber is GC'ed while suspended, do not add a ref.
516516
if (EG(fiber_error)) {
517+
// Throw UnwindExit so finally blocks are not executed on fatal error.
517518
zend_throw_unwind_exit();
518519
} else {
519-
zend_throw_fiber_exit();
520+
// Otherwise throw GracefulExit to execute finally blocks.
521+
zend_throw_graceful_exit();
520522
}
521523
RETURN_THROWS();
522524
}

0 commit comments

Comments
 (0)