You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Doug MacEachern <do...@covalent.net> on 2001/07/24 00:02:26 UTC

apr_sockaddr_info_get + server startup time

with a small number of vhosts configured, it takes ages for the server to
start.  the bottleneck is alloc_listener() -> apr_sockaddr_info_get() ->
getaddrinfo() call with the default "0.0.0.0" address.  this patch avoids
the lengthy lookup time and the server fires up right away.  could this be
done for any hostname that is an ip address (looks_like_ip(hostname)) ?
any other suggestions welcome, the current server startup time is
unbearable, especially behind a slow dialup line.

--- srclib/apr/network_io/unix/sa_common.c      2001/07/23 16:05:00    1.36
+++ srclib/apr/network_io/unix/sa_common.c      2001/07/23 21:36:43
@@ -341,7 +341,12 @@
         char num[8];
 
         memset(&hints, 0, sizeof(hints));
-        hints.ai_flags = AI_CANONNAME;
+        if (strcmp(hostname, "0.0.0.0") == 0) {
+            hints.ai_flags = AI_NUMERICHOST;
+        }
+        else {
+            hints.ai_flags = AI_CANONNAME;
+        }
         hints.ai_family = family;
         hints.ai_socktype = SOCK_STREAM;
         hints.ai_protocol = 0;



Re: apr_sockaddr_info_get + server startup time

Posted by Doug MacEachern <do...@covalent.net>.
On 23 Jul 2001, Jeff Trawick wrote:

> I was thinking that we simply needed to set hints.ai_flags to 0 (I'd
> have done it already if I were 100% sure).
> 
> Later, maybe we need to add a special flag to apr_sockaddr_info_get()
> to have it then turn on AI_CANONNAME, but for now AI_CANONNAME doesn't
> help us AFAIK.
> 
> Doesn't that do the trick for you?

sure does, thanks, i've committed that change.


Re: apr_sockaddr_info_get + server startup time

Posted by Jeff Trawick <tr...@attglobal.net>.
I was thinking that we simply needed to set hints.ai_flags to 0 (I'd
have done it already if I were 100% sure).

Later, maybe we need to add a special flag to apr_sockaddr_info_get()
to have it then turn on AI_CANONNAME, but for now AI_CANONNAME doesn't
help us AFAIK.

Doesn't that do the trick for you?

Doug MacEachern <do...@covalent.net> writes:

> with a small number of vhosts configured, it takes ages for the server to
> start.  the bottleneck is alloc_listener() -> apr_sockaddr_info_get() ->
> getaddrinfo() call with the default "0.0.0.0" address.  this patch avoids
> the lengthy lookup time and the server fires up right away.  could this be
> done for any hostname that is an ip address (looks_like_ip(hostname)) ?
> any other suggestions welcome, the current server startup time is
> unbearable, especially behind a slow dialup line.
> 
> --- srclib/apr/network_io/unix/sa_common.c      2001/07/23 16:05:00    1.36
> +++ srclib/apr/network_io/unix/sa_common.c      2001/07/23 21:36:43
> @@ -341,7 +341,12 @@
>          char num[8];
>  
>          memset(&hints, 0, sizeof(hints));
> -        hints.ai_flags = AI_CANONNAME;
> +        if (strcmp(hostname, "0.0.0.0") == 0) {
> +            hints.ai_flags = AI_NUMERICHOST;
> +        }
> +        else {
> +            hints.ai_flags = AI_CANONNAME;
> +        }
>          hints.ai_family = family;
>          hints.ai_socktype = SOCK_STREAM;
>          hints.ai_protocol = 0;
> 
> 

-- 
Jeff Trawick | trawick@attglobal.net | PGP public key at web site:
       http://www.geocities.com/SiliconValley/Park/9289/
             Born in Roswell... married an alien...

Re: apr_sockaddr_info_get + server startup time

Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
Anyone with a 'private' numeric network (e.g. .theoffice.7 ) is a dufus, +1
in theory :)  

Bill

----- Original Message ----- 
From: "Doug MacEachern" <do...@covalent.net>
To: <de...@apr.apache.org>
Sent: Monday, July 23, 2001 5:02 PM
Subject: apr_sockaddr_info_get + server startup time


> with a small number of vhosts configured, it takes ages for the server to
> start.  the bottleneck is alloc_listener() -> apr_sockaddr_info_get() ->
> getaddrinfo() call with the default "0.0.0.0" address.  this patch avoids
> the lengthy lookup time and the server fires up right away.  could this be
> done for any hostname that is an ip address (looks_like_ip(hostname)) ?
> any other suggestions welcome, the current server startup time is
> unbearable, especially behind a slow dialup line.
> 
> --- srclib/apr/network_io/unix/sa_common.c      2001/07/23 16:05:00    1.36
> +++ srclib/apr/network_io/unix/sa_common.c      2001/07/23 21:36:43
> @@ -341,7 +341,12 @@
>          char num[8];
>  
>          memset(&hints, 0, sizeof(hints));
> -        hints.ai_flags = AI_CANONNAME;
> +        if (strcmp(hostname, "0.0.0.0") == 0) {
> +            hints.ai_flags = AI_NUMERICHOST;
> +        }
> +        else {
> +            hints.ai_flags = AI_CANONNAME;
> +        }
>          hints.ai_family = family;
>          hints.ai_socktype = SOCK_STREAM;
>          hints.ai_protocol = 0;
> 
> 
> 


Re: apr_sockaddr_info_get + server startup time

Posted by Dirk-Willem van Gulik <di...@covalent.net>.
It might be worthwhile to snarf some code from (Free)BSD to also deal
with ceases like 10.2 == 10.0.0.2 and similar 'abbreviations'.

Dw

On Mon, 23 Jul 2001, Doug MacEachern wrote:

> with a small number of vhosts configured, it takes ages for the server to
> start.  the bottleneck is alloc_listener() -> apr_sockaddr_info_get() ->
> getaddrinfo() call with the default "0.0.0.0" address.  this patch avoids
> the lengthy lookup time and the server fires up right away.  could this be
> done for any hostname that is an ip address (looks_like_ip(hostname)) ?
> any other suggestions welcome, the current server startup time is
> unbearable, especially behind a slow dialup line.
>
> --- srclib/apr/network_io/unix/sa_common.c      2001/07/23 16:05:00    1.36
> +++ srclib/apr/network_io/unix/sa_common.c      2001/07/23 21:36:43
> @@ -341,7 +341,12 @@
>          char num[8];
>
>          memset(&hints, 0, sizeof(hints));
> -        hints.ai_flags = AI_CANONNAME;
> +        if (strcmp(hostname, "0.0.0.0") == 0) {
> +            hints.ai_flags = AI_NUMERICHOST;
> +        }
> +        else {
> +            hints.ai_flags = AI_CANONNAME;
> +        }
>          hints.ai_family = family;
>          hints.ai_socktype = SOCK_STREAM;
>          hints.ai_protocol = 0;
>
>
>