Return-Path: Delivered-To: apmail-httpd-cvs-archive@www.apache.org Received: (qmail 79470 invoked from network); 20 Apr 2005 20:40:50 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 20 Apr 2005 20:40:50 -0000 Received: (qmail 32902 invoked by uid 500); 20 Apr 2005 20:40:57 -0000 Delivered-To: apmail-httpd-cvs-archive@httpd.apache.org Received: (qmail 32750 invoked by uid 500); 20 Apr 2005 20:40:56 -0000 Mailing-List: contact cvs-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: Delivered-To: mailing list cvs@httpd.apache.org Received: (qmail 32735 invoked by uid 99); 20 Apr 2005 20:40:56 -0000 X-ASF-Spam-Status: No, hits=0.2 required=10.0 tests=NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Wed, 20 Apr 2005 13:40:55 -0700 Received: (qmail 79392 invoked by uid 65534); 20 Apr 2005 20:40:47 -0000 Message-ID: <20050420204047.79391.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: svn commit: r162066 - /httpd/httpd/trunk/server/util.c Date: Wed, 20 Apr 2005 20:40:46 -0000 To: cvs@httpd.apache.org From: jim@apache.org X-Mailer: svnmailer-1.0.0-dev X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: jim Date: Wed Apr 20 13:40:46 2005 New Revision: 162066 URL: http://svn.apache.org/viewcvs?rev=3D162066&view=3Drev Log: APRized ap_get_local_host() Modified: httpd/httpd/trunk/server/util.c Modified: httpd/httpd/trunk/server/util.c URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/server/util.c?rev=3D16= 2066&r1=3D162065&r2=3D162066&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- httpd/httpd/trunk/server/util.c (original) +++ httpd/httpd/trunk/server/util.c Wed Apr 20 13:40:46 2005 @@ -1977,24 +1977,6 @@ } } =20 -static char *find_fqdn(apr_pool_t *a, struct hostent *p) -{ - int x; - - if (!strchr(p->h_name, '.')) { - if (p->h_aliases) { - for (x =3D 0; p->h_aliases[x]; ++x) { - if (strchr(p->h_aliases[x], '.') && - (!strncasecmp(p->h_aliases[x], p->h_name, - strlen(p->h_name)))) - return apr_pstrdup(a, p->h_aliases[x]); - } - } - return NULL; - } - return apr_pstrdup(a, (void *) p->h_name); -} - char *ap_get_local_host(apr_pool_t *a) { #ifndef MAXHOSTNAMELEN @@ -2002,34 +1984,22 @@ #endif char str[MAXHOSTNAMELEN + 1]; char *server_hostname =3D NULL; - struct hostent *p; + apr_sockaddr_t *sockaddr; =20 -#ifdef BEOS_R5 - if (gethostname(str, sizeof(str) - 1) =3D=3D 0) -#else - if (gethostname(str, sizeof(str) - 1) !=3D 0) -#endif - { + if (apr_gethostname(str, sizeof(str) - 1, a) !=3D APR_SUCCESS) { ap_log_perror(APLOG_MARK, APLOG_STARTUP | APLOG_WARNING, 0, a, - "%s: gethostname() failed to determine ServerName", + "%s: apr_gethostname() failed to determine ServerName= ", ap_server_argv0); - } - else=20 - { + } else { str[sizeof(str) - 1] =3D '\0'; - /* TODO: Screaming for APR-ization */ - if ((!(p =3D gethostbyname(str)))=20 - || (!(server_hostname =3D find_fqdn(a, p)))) { - /* Recovery - return the default servername by IP: */ - if (p && p->h_addr_list[0]) { - apr_snprintf(str, sizeof(str), "%pA", p->h_addr_list[0]); - server_hostname =3D apr_pstrdup(a, str); - /* We will drop through to report the IP-named server */ - } - } - else { - /* Since we found a fdqn, return it with no logged message. */ + if (apr_sockaddr_info_get(&sockaddr, str, AF_INET, 0, 0, a) =3D=3D= APR_SUCCESS) { + server_hostname =3D apr_pstrdup(a, sockaddr->hostname); return server_hostname; + } else { + ap_log_perror(APLOG_MARK, APLOG_STARTUP | APLOG_WARNING, 0, a, + "%s: apr_sockaddr_info_get() failed for hostname = '%s'", + ap_server_argv0, str); + server_hostname =3D apr_pstrdup(a, str); } } =20