httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Schulze ...@bytecamp.net>
Subject what should be done in a vhost_db module?
Date Fri, 04 Apr 2008 09:59:08 GMT
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

Mime
View raw message