diff --git a/examples/fs_poll.php b/examples/fs_poll.php index 58b2375..90ddf7b 100644 --- a/examples/fs_poll.php +++ b/examples/fs_poll.php @@ -4,7 +4,7 @@ $poll = uv_fs_poll_init(uv_default_loop()); uv_fs_poll_start($poll,function($rsc,$stat,$p){ var_dump(1); var_dump($p); - uv_fs_poll_stop($rsc); + //uv_fs_poll_stop($rsc); }, "/tmp/hoge", 1); diff --git a/php_uv.c b/php_uv.c index 3c3d932..efedc40 100644 --- a/php_uv.c +++ b/php_uv.c @@ -6185,6 +6185,11 @@ PHP_FUNCTION(uv_fs_poll_start) } ZEND_FETCH_RESOURCE(uv, php_uv_t *, &handle, -1, PHP_UV_RESOURCE_NAME, uv_resource_handle); + + if (uv->type != IS_UV_FS_POLL) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "passed uv resource didn't initialize for uv_fs_poll"); + RETURN_FALSE; + } php_uv_cb_init(&cb, uv, &fci, &fcc, PHP_UV_FS_POLL_CB); uv->uv.fs_poll.data = uv; @@ -6211,6 +6216,12 @@ PHP_FUNCTION(uv_fs_poll_stop) } ZEND_FETCH_RESOURCE(uv, php_uv_t *, &poll, -1, PHP_UV_RESOURCE_NAME, uv_resource_handle); + + if (uv->type != IS_UV_FS_POLL) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "passed uv resource didn't initialize for uv_fs_poll"); + RETURN_FALSE; + } + uv_fs_poll_stop(&uv->uv.fs_poll); PHP_UV_DEBUG_RESOURCE_REFCOUNT(uv_fs_poll_stop, uv->resource_id); }