scottmac                                 Thu, 06 Aug 2009 04:37:07 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=286865

Log:
Deal with moving to res_nsearch(). dns_search() on OSX lacks an error handler, 
might revert to using straight bind9.

Changed paths:
    U   php/php-src/trunk/ext/standard/dns.c
    U   php/php-src/trunk/ext/standard/php_dns.h

Modified: php/php-src/trunk/ext/standard/dns.c
===================================================================
--- php/php-src/trunk/ext/standard/dns.c        2009-08-06 04:33:18 UTC (rev 
286864)
+++ php/php-src/trunk/ext/standard/dns.c        2009-08-06 04:37:07 UTC (rev 
286865)
@@ -809,10 +809,14 @@

                        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");
+                       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);
-                               php_dns_free_handle(handle);
                                RETURN_FALSE;
                        }

@@ -845,33 +849,33 @@
                                        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);
                }
        }
 }

Modified: php/php-src/trunk/ext/standard/php_dns.h
===================================================================
--- php/php-src/trunk/ext/standard/php_dns.h    2009-08-06 04:33:18 UTC (rev 
286864)
+++ php/php-src/trunk/ext/standard/php_dns.h    2009-08-06 04:37:07 UTC (rev 
286865)
@@ -28,17 +28,25 @@
                ((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


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to