On Sat, Jan 03, 2015 at 04:40:19PM +0100, Christopher Zimmermann wrote:
> Hi,
> 
> 
> On Sat, 3 Jan 2015 14:42:18 +0100 Reyk Floeter <r...@openbsd.org> wrote:
> 
> > On Thu, Jan 01, 2015 at 11:54:46PM -0500, Geoff Steckel wrote:
> > > Is there any way todo the equivalent of:
> > > 
> > > server "an.example.com"
> > >     listen on 192.168.2.99
> > >     listen on 2001.fefe.1.1::99
> > 
> > I used "include" directives to avoid duplications (see previous reply)
> > but the following diff allows to add aliases and multiple listen
> > statements.
> > 
> > Reyk
> 
> As I understand your diff you will duplicate the entire struct
> server_config for each combination of hostname (alias), listen address
> and location section.

Correct.

> Isn't this overkill?

No, it is just a few K per server block that is allocated once on
startup.  How many aliases do you have?

My tests show that memory usage is not the problem but that there's
indeed a problem with the pre-opened file descriptors for servers;
something that is not necessary with aliases. A simple fix will follow.

> To me it seems like server_config is serving too much purposes here. A
> clean design should split up the struct server_config into one struct
> for connection settings, which will contain a TAILQ of hostnames, a
> TAILQ of listen addresses and a TAILQ of structs with location settings:
> 

"A clean design should ..."

One could argue that a clean design wouldn't try to add too many
layers of indirection that add code complexity and kill some of the
flexibility that we have with the current implementation.  I might
split up struct server_config at some point, when it is really needed,
but it is not the right time.

> TAILQ_HEAD(hostnames, char*);
> 
> struct server_config {
>       char                            location[NAME_MAX];
>       char                            root[MAXPATHLEN];
>       [...]
> }
> TAILQ_HEAD(server_configs, server_config);
> 
> struct serverhost {
>       struct sockaddr_storages        *srv_ss;
>       char                            *tls_cert;
>       int                              tcpbufsize;
>       [... other connection settings ...]
>       struct hostnames                *srv_names;
>       struct server_configs           *srv_confs;
> }
> 
> 
> For now you could simply loop over a TAILQ of hostnames in
> server_privinit() and add an inner LOOP in server_response() searching
> for the hostname/aliases.
> 
> 

Which makes the implementation more complicated, especially the reload
and privsep code, adds additional loops to save a few bytes of memory.

Don't get me wrong - I do care about memory usage - but this is not
per connection - it is persistent during runtime.

Reyk

Reply via email to