Skip to content

Refactor Fiber internal implementation #7085

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Zend/tests/fibers/resume-non-running-fiber.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ $fiber->resume();

?>
--EXPECTF--
Fatal error: Uncaught FiberError: Cannot resume a fiber that is not suspended in %sresume-non-running-fiber.php:%d
Fatal error: Uncaught FiberError: Fiber has not started in %sresume-non-running-fiber.php:%d
Stack trace:
#0 %sresume-non-running-fiber.php(%d): Fiber->resume()
#1 {main}
Expand Down
2 changes: 1 addition & 1 deletion Zend/tests/fibers/resume-running-fiber.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ $fiber->start();

?>
--EXPECTF--
Fatal error: Uncaught FiberError: Cannot resume a fiber that is not suspended in %sresume-running-fiber.php:%d
Fatal error: Uncaught FiberError: Fiber is running in %sresume-running-fiber.php:%d
Stack trace:
#0 %sresume-running-fiber.php(%d): Fiber->resume()
#1 [internal function]: {closure}()
Expand Down
2 changes: 1 addition & 1 deletion Zend/tests/fibers/resume-terminated-fiber.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ $fiber->resume();

?>
--EXPECTF--
Fatal error: Uncaught FiberError: Cannot resume a fiber that is not suspended in %sresume-terminated-fiber.php:%d
Fatal error: Uncaught FiberError: Fiber is dead in %sresume-terminated-fiber.php:%d
Stack trace:
#0 %sresume-terminated-fiber.php(%d): Fiber->resume()
#1 {main}
Expand Down
2 changes: 1 addition & 1 deletion Zend/tests/fibers/suspend-outside-fiber.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ $value = Fiber::suspend(1);

?>
--EXPECTF--
Fatal error: Uncaught FiberError: Cannot suspend outside of a fiber in %ssuspend-outside-fiber.php:%d
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in this particular instance the old description is more obvious than "nowhere to go".

Fatal error: Uncaught FiberError: Fiber has nowhere to go in %ssuspend-outside-fiber.php:%d
Stack trace:
#0 %ssuspend-outside-fiber.php(%d): Fiber::suspend(1)
#1 {main}
Expand Down
2 changes: 1 addition & 1 deletion Zend/tests/fibers/throw-into-non-running-fiber.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ $fiber->throw(new Exception('test'));

?>
--EXPECTF--
Fatal error: Uncaught FiberError: Cannot resume a fiber that is not suspended in %sthrow-into-non-running-fiber.php:%d
Fatal error: Uncaught FiberError: Fiber has not started in %sthrow-into-non-running-fiber.php:%d
Stack trace:
#0 %sthrow-into-non-running-fiber.php(%d): Fiber->throw(Object(Exception))
#1 {main}
Expand Down
18 changes: 16 additions & 2 deletions Zend/zend.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,25 @@ static ZEND_INI_MH(OnSetExceptionStringParamMaxLen) /* {{{ */

static ZEND_INI_MH(OnUpdateFiberStackSize) /* {{{ */
{
zend_long size;

if (new_value) {
EG(fiber_stack_size) = zend_atol(ZSTR_VAL(new_value), ZSTR_LEN(new_value));
size = zend_atol(ZSTR_VAL(new_value), ZSTR_LEN(new_value));
if (size == 0) {
size = ZEND_FIBER_DEFAULT_C_STACK_SIZE;
} else if (size < ZEND_FIBER_MIN_C_STACK_SIZE) {
size = ZEND_FIBER_MIN_C_STACK_SIZE;
} else if (size > ZEND_FIBER_MAX_C_STACK_SIZE) {
size = ZEND_FIBER_MAX_C_STACK_SIZE;
} else {
size = ZEND_MM_ALIGNED_SIZE_EX(size, ZEND_FIBER_C_STACK_ALIGNMENT);
}
} else {
EG(fiber_stack_size) = ZEND_FIBER_DEFAULT_C_STACK_SIZE;
size = ZEND_FIBER_DEFAULT_C_STACK_SIZE;
}

EG(fiber_stack_size) = size;

return SUCCESS;
}
/* }}} */
Expand Down
1 change: 1 addition & 0 deletions Zend/zend_execute_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ void shutdown_executor(void) /* {{{ */

zend_objects_store_free_object_storage(&EG(objects_store), fast_shutdown);

zend_fiber_shutdown();
zend_weakrefs_shutdown();

zend_try {
Expand Down
Loading