From 2798970b49a076af33d78095c9cd870f50afb65d Mon Sep 17 00:00:00 2001 From: Andrey Kostylev Date: Fri, 24 Feb 2017 18:27:24 +0300 Subject: [PATCH] garbage resource after uv_close --- php_uv.c | 5 +++++ tests/006-uv_async_init-no-memory-leak.phpt | 25 +++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 tests/006-uv_async_init-no-memory-leak.phpt diff --git a/php_uv.c b/php_uv.c index 6f388fb..d1d6040 100644 --- a/php_uv.c +++ b/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); } /* }}} */ diff --git a/tests/006-uv_async_init-no-memory-leak.phpt b/tests/006-uv_async_init-no-memory-leak.phpt new file mode 100644 index 0000000..be20ce2 --- /dev/null +++ b/tests/006-uv_async_init-no-memory-leak.phpt @@ -0,0 +1,25 @@ +--TEST-- +Check uv_async has no memory leak +--FILE-- +