Re: PHP 4.0 Bug #7880 Updated: PHP_URL_FOPEN doesn't work

From: Date: Sun, 31 Dec 2000 01:31:27 +0000
Subject: Re: PHP 4.0 Bug #7880 Updated: PHP_URL_FOPEN doesn't work
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-42631@lists.php.net to get a copy of this message
php-de>No feedback. Reopen if this really doesn't work with correct url. I sent an email to jason@php.net with the following information. I was unable to update the ticket online with this information for some reason. This "really doesn't work.": Date: Sat, 23 Dec 2000 02:34:02 -0500 (EST) To: jason@php.net Subject: PHP 4.0 Bug #7880 Updated: PHP_URL_FOPEN doesn't work Could you please add this to your PHP bug? ========================================== Ok - I seem to have tracked this down. I added debug statements throughout PHP to see exactly where it was failing, and found that it is happening in: php_network_getaddresses in main/network.c. Basically, in php_fopen_url_wrap_http in ext/standard/http_fopen_wrapper.c, I modified the function to let me know where it was bailing: *socketd = php_hostconnect(resource->host, resource->port, SOCK_STREAM, 0); if (*socketd == -1) { php_error(E_WARNING, "php_hostconnect failed"); SOCK_FCLOSE(*socketd); *socketd = 0; free_url(resource); return NULL; } It does get to that php_error message, and so after looking through php_hostconnect, I found that our problem was a failed lookup in php_network_getaddresses. Here is my slightly modified code that prints out an error message when getaddrinfo fails: static int php_network_getaddresses(const char *host, struct sockaddr ***sal) { int err; struct sockaddr **sap; if (host != NULL) { #ifdef HAVE_GETADDRINFO struct addrinfo hints, *res, *sai; int n; memset( &hints, '\0', sizeof(hints) ); hints.ai_family = AF_UNSPEC; if ((err = getaddrinfo(host, NULL, &hints, &res))) { php_error(E_WARNING, "getaddrinfo failed for host: %s with error: %d", host, err); php_error(E_WARNING, gai_strerror(err)); return -1; } I took a look at php 4.0.2 (which is working fine for us), and saw that it doesn't use getaddrinfo for hostname lookups, it uses the gethostbyname function. I'm not familiar enough with the getaddrinfo call to tell you if it is failing because of a bug in Solaris, a problem in our system configuration, or if it is a problem with the php source. I have created two testpages that are failing for us, one with a numeric IP address and another with a hostname that must be resolved. You can view them here: Use of the "file" function on a numeric address: http://pkw.devilnet.duke.edu/testweather.php Use of the "file" function on a hostname that must be resolved: http://dev.dspconline.org/scripts/update_weather.php I hope this helps. ========================================== Alan -- Alan Halachmi Wide Area Network Specialist Ingram Entertainment Network Services mailto:alan@halachmi.net http://www.ingramentertainment.com

« previous php.dev (#42631) next »