n = php_dns_search(handle, hostname, C_IN, type_to_fetch, answer.qb2, sizeof answer);
- if (n < 0 ) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "res_nsearch() failed");
- zval_dtor(return_value);
+ if (n < 0) {
+ if (php_dns_errno(handle) == NO_DATA) {
+ php_dns_free_handle(handle);
+ continue;
+ }
+
php_dns_free_handle(handle);
+ zval_dtor(return_value);
RETURN_FALSE;
}
add_next_index_zval(return_value, retval);
}
}
- php_dns_free_handle(handle);
- }
- }
- if (authns || addtl) {
- /* List of Authoritative Name Servers
- * Process when only requesting addtl so that we can skip through the section
- */
- while (ns-- > 0 && cp && cp < end) {
- zval *retval = NULL;
+ if (authns || addtl) {
+ /* List of Authoritative Name Servers
+ * Process when only requesting addtl so that we can skip through the section
+ */
+ while (ns-- > 0 && cp && cp < end) {
+ zval *retval = NULL;
- cp = php_parserr(cp, &answer, DNS_T_ANY, authns != NULL, &retval TSRMLS_CC);
- if (retval != NULL) {
- add_next_index_zval(authns, retval);
+ cp = php_parserr(cp, &answer, DNS_T_ANY, authns != NULL, &retval TSRMLS_CC);
+ if (retval != NULL) {
+ add_next_index_zval(authns, retval);
+ }
+ }
}
- }
- }
- if (addtl) {
- /* Additional records associated with authoritative name servers */
- while (ar-- > 0 && cp && cp < end) {
- zval *retval = NULL;
+ if (addtl) {
+ /* Additional records associated with authoritative name servers */
+ while (ar-- > 0 && cp && cp < end) {
+ zval *retval = NULL;
- cp = php_parserr(cp, &answer, DNS_T_ANY, 1, &retval TSRMLS_CC);
- if (retval != NULL) {
- add_next_index_zval(addtl, retval);
+ cp = php_parserr(cp, &answer, DNS_T_ANY, 1, &retval TSRMLS_CC);
+ if (retval != NULL) {
+ add_next_index_zval(addtl, retval);
+ }
+ }
}
+ php_dns_free_handle(handle);
}
}
}
((int)dns_search(res, dname, class, type, answer, anslen, (struct sockaddr *)&from, &fromsize))
#define php_dns_free_handle(res) \
dns_free(res)
+#define php_dns_errno(_res) \
+ (NO_DATA)
#elif defined(HAVE_RES_NSEARCH)
#define php_dns_search(res, dname, class, type, answer, anslen) \
res_nsearch(res, dname, class, type, answer, anslen)
-#define php_dns_free_handle(res) \
- res_nclose(res)
+#define php_dns_free_handle(res) \
+ res_nclose(res); \
+ php_dns_free_res(*res)
+
+#define php_dns_errno(res) \
+ (res->res_h_errno)
#elif defined(HAVE_RES_SEARCH)
#define php_dns_search(res, dname, class, type, answer, anslen) \
res_search(dname, class, type, answer, anslen)
#define php_dns_free_handle(res) /* noop */
+#define php_dns_errno(res) \
+ (_res.res_h_errno)
#endif