Skip to content

Commit 388d31b

Browse files
committed
Return previous context from zend_fiber_switch_context
1 parent a392556 commit 388d31b

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Zend/zend_fibers.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ ZEND_API void zend_fiber_destroy_context(zend_fiber_context *context)
226226
zend_fiber_stack_free(&context->stack);
227227
}
228228

229-
ZEND_API void zend_fiber_switch_context(zend_fiber_context *to)
229+
ZEND_API zend_fiber_context *zend_fiber_switch_context(zend_fiber_context *to)
230230
{
231231
zend_fiber_context *from = EG(current_fiber);
232232
zend_fiber_vm_state state;
@@ -283,6 +283,8 @@ ZEND_API void zend_fiber_switch_context(zend_fiber_context *to)
283283
if (previous->status == ZEND_FIBER_STATUS_DEAD) {
284284
zend_fiber_destroy_context(to);
285285
}
286+
287+
return previous;
286288
}
287289

288290

Zend/zend_fibers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ ZEND_API void zend_fiber_throw(zend_fiber *fiber, zval *exception, zval *return_
133133
/* These functions may be used to create custom fibers (coroutines) using the bundled fiber switching context. */
134134
ZEND_API bool zend_fiber_init_context(zend_fiber_context *context, void *kind, zend_fiber_coroutine coroutine, size_t stack_size);
135135
ZEND_API void zend_fiber_destroy_context(zend_fiber_context *context);
136-
ZEND_API void zend_fiber_switch_context(zend_fiber_context *to);
136+
ZEND_API zend_fiber_context *zend_fiber_switch_context(zend_fiber_context *to);
137137

138138
END_EXTERN_C()
139139

0 commit comments

Comments
 (0)