On Fri, 04 Apr 2008 11:59:08 +0200
Robert Schulze <[EMAIL PROTECTED]> wrote:

> Hi,
> 
> I'm currently working on a module to create virtualhosts on the fly
> out of a cdb-database file.
> 
> I looked at some module which do basically the same with other data 
> sources. What I now wonder is, what else I have to do except for
> setting the r->filename and maybe some script-alias-foo.
> 
> In one module I saw the following:
> 
> 8<--------------------------------------------------------------------
> 
> request_rec *top = (r->main)?r->main:r;
> 
> /* ... */
> 
> top->server->server_hostname = apr_pstrdup (top->pool, hostname);
> 
> r->parsed_uri.hostinfo =
> apr_pstrdup(r->pool,r->server->server_hostname);
> 
> r->parsed_uri.hostname =
> apr_pstrdup(r->pool,r->server->server_hostname);
> 
> 8<--------------------------------------------------------------------
> 
> and thats exactly where I got some problems.
> I sometimes noticed, that the virtual host name in /server-status/ 
> contained only weird characters, which I think is a result of freeing
> a buffer which is currently in use.
> I think the problem is the wrong pool for allocating space for the 
> server_hostname.
> 
> I thought I fixed that with this solution:
> 
> 8<--------------------------------------------------------------------
> 
> if(r->hostname!=NULL)
>          {
>          r->server->server_hostname =
> apr_pstrdup(r->connection->pool, r->hostname);
>          r->parsed_uri.hostinfo = 
> apr_pstrdup(r->pool,r->server->server_hostname);
>          r->parsed_uri.hostname = 
> apr_pstrdup(r->pool,r->server->server_hostname);
>          }
> 
> 8<--------------------------------------------------------------------
> 
> But that didn't fix the problem completely.
> 
> My question now: do I have to set server->server_hostname and if so, 
> from which pool should I allocate the memory from?
> 
> with kind regards,
> 
> Robert Schulze

I'm not sure that I understand what you're doing here by creating
virtual hosts on the fly, do you mean in real time to the database of
virtual hosts updating - that would perhaps be a lot of work that isn't
normally required during the request, why not signal the apache server
to reload it's config when the db changes?

Are you doing this to save memory? Maybe mod_safeinclude would be of
some use to you, which does populate virtual hosts from a DB.

-- 
The PRI to Alderan is strobing because of Brad White.
Tech Support is taking a percodan.
:: http://www.s5h.net/ :: http://www.s5h.net/gpg.html

Attachment: signature.asc
Description: PGP signature

Reply via email to