File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -294,6 +294,26 @@ struct _zend_async_microtask_s {
294
294
uint32_t ref_count ;
295
295
};
296
296
297
+ #define ZEND_ASYNC_MICROTASK_ADD_REF (microtask ) \
298
+ do { \
299
+ if (microtask != NULL) { \
300
+ microtask->ref_count++; \
301
+ } \
302
+ } while (0)
303
+
304
+ #define ZEND_ASYNC_MICROTASK_RELEASE (microtask ) \
305
+ do { \
306
+ if (microtask != NULL && microtask->ref_count > 1) { \
307
+ microtask->ref_count--; \
308
+ } else { \
309
+ microtask->ref_count = 0; \
310
+ if (microtask->dtor) { \
311
+ microtask->dtor(microtask); \
312
+ } \
313
+ efree(microtask); \
314
+ } \
315
+ } while (0)
316
+
297
317
///////////////////////////////////////////////////////////////////
298
318
/// Async iterator structures
299
319
///////////////////////////////////////////////////////////////////
Original file line number Diff line number Diff line change @@ -1975,6 +1975,11 @@ static void zend_gc_collect_cycles_coroutine(void)
1975
1975
1976
1976
ZEND_ASYNC_ADD_MICROTASK (GC_G (microtask ));
1977
1977
zend_gc_collect_cycles ();
1978
+
1979
+ if (GC_G (microtask ) != NULL ) {
1980
+ GC_G (microtask )-> is_cancelled = true;
1981
+ ZEND_ASYNC_MICROTASK_RELEASE (GC_G (microtask ));
1982
+ }
1978
1983
}
1979
1984
1980
1985
static zend_string * coroutine_info (zend_async_event_t * event )
You can’t perform that action at this time.
0 commit comments