Skip to content

Commit 322e26a

Browse files
committed
php#53: Fix 010-stream_select_async and issue with poll event => proxy_event
1 parent e92dacc commit 322e26a

File tree

3 files changed

+6
-19
lines changed

3 files changed

+6
-19
lines changed

Zend/zend_async_API.c

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -885,24 +885,10 @@ ZEND_API void zend_async_waker_callback_resolve(zend_async_event_t *event,
885885
{
886886
zend_coroutine_t *coroutine = ((zend_coroutine_event_callback_t *) callback)->coroutine;
887887

888-
if (exception == NULL && coroutine->waker != NULL) {
889-
890-
if (coroutine->waker->triggered_events == NULL) {
891-
coroutine->waker->triggered_events = (HashTable *) emalloc(sizeof(HashTable));
892-
zend_hash_init(
893-
coroutine->waker->triggered_events, 2, NULL, waker_triggered_events_dtor, 0);
894-
}
895-
896-
if (EXPECTED(zend_hash_index_add_ptr(
897-
coroutine->waker->triggered_events, (zend_ulong) event, event)
898-
!= NULL)) {
899-
ZEND_ASYNC_EVENT_ADD_REF(event);
900-
}
901-
888+
if (exception == NULL && coroutine->waker != NULL
889+
&& ZEND_ASYNC_EVENT_WILL_ZVAL_RESULT(event) && result != NULL) {
902890
// Copy the result to the waker if it is not NULL
903-
if (ZEND_ASYNC_EVENT_WILL_ZVAL_RESULT(event) && result != NULL) {
904-
ZVAL_COPY(&coroutine->waker->result, result);
905-
}
891+
ZVAL_COPY(&coroutine->waker->result, result);
906892
}
907893

908894
if (exception != NULL) {
@@ -962,7 +948,7 @@ ZEND_API zend_async_waker_t *zend_async_waker_new_with_timeout(
962948

963949
if (timeout > 0) {
964950
zend_async_resume_when(coroutine, &ZEND_ASYNC_NEW_TIMER_EVENT(timeout, false)->base, true,
965-
zend_async_waker_callback_resolve, NULL);
951+
zend_async_waker_callback_timeout, NULL);
966952
}
967953

968954
if (cancellation != NULL) {

Zend/zend_async_API.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,7 @@ struct _zend_async_poll_proxy_s {
692692
zend_async_event_t base;
693693
zend_async_poll_event_t *poll_event;
694694
async_poll_event events;
695+
async_poll_event triggered_events;
695696
};
696697

697698
struct _zend_async_timer_event_s {

main/network_async.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ static void async_stream_callback_resolve(
880880
if (EXPECTED(coroutine->waker != NULL)) {
881881
async_stream_callback_t *stream_callback = (async_stream_callback_t *)callback;
882882

883-
zend_async_poll_event_t *poll_event = (zend_async_poll_event_t *)event;
883+
zend_async_poll_proxy_t *poll_event = (zend_async_poll_proxy_t *)event;
884884

885885
// Immediately add ready stream to appropriate result array with preserved key
886886
zval stream_zval;

0 commit comments

Comments
 (0)