garbage resource after uv_close

This commit is contained in:
Andrey Kostylev 2017-02-24 18:27:24 +03:00
parent 3815766985
commit 2798970b49
2 changed files with 30 additions and 0 deletions

View File

@ -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(&params[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);
}
/* }}} */

View 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