Free loop handle only when object freed

This commit is contained in:
Aaron Piotrowski 2021-11-11 18:51:38 -06:00
parent 4608148622
commit 3c89bc46a5
No known key found for this signature in database
GPG Key ID: ADD1EF783EDE9EEB

View File

@ -1250,7 +1250,14 @@ void static destruct_uv_loop(zend_object *obj)
/* for proper destruction: close all handles, let libuv call close callback and then close and free the loop */
uv_walk(loop, destruct_uv_loop_walk_cb, NULL);
uv_run(loop, UV_RUN_DEFAULT);
uv_loop_close(loop);
}
}
void static free_uv_loop(zend_object *obj)
{
php_uv_loop_t *loop_obj = (php_uv_loop_t *) obj;
if (loop_obj != UV_G(default_loop)) {
uv_loop_close(&loop_obj->loop);
}
if (loop_obj->gc_buffer) {
efree(loop_obj->gc_buffer);
@ -2751,6 +2758,7 @@ PHP_MINIT_FUNCTION(uv)
memcpy(&uv_loop_handlers, &uv_default_handlers, sizeof(zend_object_handlers));
uv_loop_handlers.get_gc = php_uv_loop_get_gc;
uv_loop_handlers.dtor_obj = destruct_uv_loop;
uv_loop_handlers.free_obj = free_uv_loop;
uv_sockaddr_ce = php_uv_register_internal_class("UVSockAddr");
uv_sockaddr_ce->ce_flags |= ZEND_ACC_ABSTRACT;