mirror of
https://github.com/danog/ext-uv.git
synced 2024-11-30 04:29:01 +01:00
garbage resource after uv_close
This commit is contained in:
parent
3815766985
commit
2798970b49
5
php_uv.c
5
php_uv.c
@ -2097,6 +2097,10 @@ static void php_uv_close_cb(uv_handle_t *handle)
|
||||
|
||||
uv->in_free = -1;
|
||||
|
||||
if (GC_REFCOUNT(uv->resource_id) > 1) {
|
||||
zend_list_delete(uv->resource_id);
|
||||
}
|
||||
|
||||
zval_ptr_dtor(¶ms[0]); /* call destruct_uv */
|
||||
}
|
||||
|
||||
@ -5623,6 +5627,7 @@ PHP_FUNCTION(uv_async_init)
|
||||
|
||||
ZVAL_RES(return_value, uv->resource_id);
|
||||
GC_REFCOUNT(uv->resource_id)++;
|
||||
PHP_UV_DEBUG_RESOURCE_REFCOUNT(uv_async_init, uv->resource_id);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
25
tests/006-uv_async_init-no-memory-leak.phpt
Normal file
25
tests/006-uv_async_init-no-memory-leak.phpt
Normal file
@ -0,0 +1,25 @@
|
||||
--TEST--
|
||||
Check uv_async has no memory leak
|
||||
--FILE--
|
||||
<?php
|
||||
$m = memory_get_usage();
|
||||
|
||||
$loop = uv_loop_new();
|
||||
|
||||
for ($i = 0; $i < 1; $i++) {
|
||||
$async = uv_async_init($loop, static function ($async) {
|
||||
uv_close($async);
|
||||
});
|
||||
|
||||
uv_async_send($async);
|
||||
}
|
||||
|
||||
unset($async);
|
||||
|
||||
uv_run($loop, UV::RUN_DEFAULT);
|
||||
uv_loop_delete($loop);
|
||||
unset($loop);
|
||||
|
||||
echo memory_get_usage() - $m, PHP_EOL;
|
||||
--EXPECTF--
|
||||
0
|
Loading…
Reference in New Issue
Block a user