ID:               50807
 Comment by:       skasun at tucson dot com
 Reported By:      skasun at tucson dot com
 Status:           Feedback
 Bug Type:         Network related
 Operating System: OS X Leopard Server
 PHP Version:      5.3.1
 New Comment:

Just a follow up, it is indeed not PHP's fault (thanks Rasmus, your 
response helped us determine the true cause).

We have determined that launching a background process (apache for 
example) from the command line and then logging out will cause OSX to 
flag that process's Context for garbage collection. That will prevent 
that process's children from looking up Mach ports, which will cause 
getaddrinfo to return EAI_AGAIN. Since not all children are GC'd, some

apache processes work, others fail.

Apparently this affects Leopard and Snow Leopard.  Our fix was as
simple 
as running Apache from GNU screen.


Previous Comments:
------------------------------------------------------------------------

[2010-01-20 18:30:08] [email protected]

PHP doesn't do anything magic here.  We are simply calling your
system's getaddrinfo function.  The code looks like this:

    if ((n = getaddrinfo(host, NULL, &hints, &res))) {
            php_error_docref(NULL TSRMLS_CC, E_WARNING,
"php_network_getaddresses: getaddrinfo failed: %s",
PHP_GAI_STRERROR(n));
        }

getaddrinfo() returns 0 on success.  And as you can see from the code,
the error is coming from your getaddrinfo() low-level call.  That error
message corresponds to an EAI_AGAIN error from the call.  On my system
the man page just says:

       EAI_AGAIN
              The name server returned a temporary failure indication. 
Try again later.

So, I am not sure how to help you here.  I see nothing wrong with the
code as evidenced by the fact that it works most of the time for you. 
Can you check the logs of your dns server and see why you might be
getting temporary failures there?

------------------------------------------------------------------------

[2010-01-20 18:20:51] skasun at tucson dot com

Description:
------------
We keep sporadically getting this error:

Warning: file_get_contents() [function.file-get-contents]:
php_network_getaddresses: getaddrinfo failed: Temporary failure in name
resolution in [path to script] on line XX

It has nothing to do with DNS on the machine. I can have dns_get_record
return a valid response on the exact same page as that error. It's also
not consistent.  getaddrinfo works 90% of the time, but randomly,
without any changes to the machine or the scripts, it will give the
above error.

Reproduce code:
---------------
$page=file_get_contents("http://google.com";);

Expected result:
----------------
The contents of google.com gets put into $page

Actual result:
--------------
90% of the time, we get the expected result.. but then it will start
failing and it may take several page reloads for it to start magically
working again.

Warning: file_get_contents() [function.file-get-contents]:
php_network_getaddresses: getaddrinfo failed: Temporary failure in name
resolution in [path to script] on line XX


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=50807&edit=1

Reply via email to