poll: checks uv resource type

This commit is contained in:
Shuhei Tanuma 2012-07-28 01:59:01 +09:00
parent 07122e463e
commit 1c0ed4c82c

View File

@ -6129,6 +6129,11 @@ PHP_FUNCTION(uv_poll_start)
} }
ZEND_FETCH_RESOURCE(uv, php_uv_t *, &handle, -1, PHP_UV_RESOURCE_NAME, uv_resource_handle); ZEND_FETCH_RESOURCE(uv, php_uv_t *, &handle, -1, PHP_UV_RESOURCE_NAME, uv_resource_handle);
if (uv->type != IS_UV_POLL) {
php_error_docref(NULL TSRMLS_CC, "passed resource didn't initialize for uv_poll");
RETURN_FALSE;
}
php_uv_cb_init(&cb, uv, &fci, &fcc, PHP_UV_POLL_CB); php_uv_cb_init(&cb, uv, &fci, &fcc, PHP_UV_POLL_CB);
uv->uv.poll.data = uv; uv->uv.poll.data = uv;
@ -6156,6 +6161,12 @@ PHP_FUNCTION(uv_poll_stop)
} }
ZEND_FETCH_RESOURCE(uv, php_uv_t *, &poll, -1, PHP_UV_RESOURCE_NAME, uv_resource_handle); ZEND_FETCH_RESOURCE(uv, php_uv_t *, &poll, -1, PHP_UV_RESOURCE_NAME, uv_resource_handle);
if (uv->type != IS_UV_POLL) {
php_error_docref(NULL TSRMLS_CC, "passed resource didn't initialize for uv_poll");
RETURN_FALSE;
}
uv_poll_stop(&uv->uv.poll); uv_poll_stop(&uv->uv.poll);
PHP_UV_DEBUG_RESOURCE_REFCOUNT(uv_poll_stop, uv->resource_id); PHP_UV_DEBUG_RESOURCE_REFCOUNT(uv_poll_stop, uv->resource_id);
} }