diff --git a/php_uv.c b/php_uv.c index 61e8c74..54be177 100644 --- a/php_uv.c +++ b/php_uv.c @@ -3095,6 +3095,10 @@ PHP_FUNCTION(ares_gethostbyname) } ZEND_FETCH_RESOURCE(uv, php_uv_ares_t *, &handle, -1, PHP_UV_ARES_RESOURCE_NAME, uv_ares_handle); + if (uv->gethostbyname_cb != NULL) { + zval_ptr_dtor(&uv->gethostbyname_cb); + uv->gethostbyname_cb = NULL; + } Z_ADDREF_P(byname_cb); uv->gethostbyname_cb = byname_cb; diff --git a/tests/200-ares_gethostbyname.phpt b/tests/200-ares_gethostbyname.phpt new file mode 100644 index 0000000..cf00a5d --- /dev/null +++ b/tests/200-ares_gethostbyname.phpt @@ -0,0 +1,35 @@ +--TEST-- +Check for ares_gethostbyname +--FILE-- + array( + "8.8.8.8" + ), + "port"=>53 +),null); + +ares_gethostbyname($uv,"php.net",AF_INET, function($name, $addr){ + echo $name . PHP_EOL; + if (is_array($addr)) { + echo "OK"; + } else { + echo "FAILED"; + } +}); + +ares_gethostbyname($uv,"php.net",AF_INET, function($name, $addr){ + echo $name . PHP_EOL; + if (is_array($addr)) { + echo "OK" . PHP_EOL; + } else { + echo "FAILED: 2nd parameter does not array" . PHP_EOL; + } +}); + +uv_run(); +--EXPECT-- +php.net +OK +php.net +OK \ No newline at end of file