Re: what should be done in a vhost_db module?
Robert Schulze wrote: Tom Donovan schrieb: In a threaded mpm, the same r-server struct is used by multiple requests simultaneously. It isn't safe to change anything in it on the fly. OK, thats a pity. I now tried to set several other variables (Host in r-headers_in, r-hostname, etc.) but all those settings did not set the hostname of the virtualhost. You can see that by inspecting /server-status/ and have a look at accesslogs. There will always be the main servername used instead of anything crafted from the module. In this way, this stuff is useless :-( Does anybody know, how to set the hostname for the virtualhost correctly, so that other modules might gather the correct info from the request? One more bad thing is, that one can't set the DocumentRoot without (once again) playing with the core configuration. Simply setting apr_table_set(r-subprocess_env, DOCUMENT_ROOT,/foo/var); is not enough, since that value will magically become overwritten by later work from apache :-( BTW: I looked at mod_vhost_alias, mod_vhost_dbi, mod_vhost_ldap, mod_vhost-modules to get knowledge about how to write a module and so on, so please point me to them :-) The magic all happens in the : ap_hook_translate_name hook. That is the function to examine to see what it does. -- Joseph Lewis http://sharktooth.org/
Re: what should be done in a vhost_db module?
Hi, ed schrieb: I'm not sure that I understand what you're doing here by creating virtual hosts on the fly, I mean, on request basis (from a db). So what I wanted to know is, whether there are any hints, what a mod_vhost_??? module is supposed to do (or set). I'm now setting r-server-server_hostname by allocating space from r-server-process-pool so I hope I have fixed the memory issues. Are you doing this to save memory? This is one important fact - it saves a huge amount of memory with several thousands of virtualhosts. One more interesting thing is, that apache does not need to be restarted when adding domains :-) Rob
Re: what should be done in a vhost_db module?
Robert Schulze wrote: Hi, I'm currently working on a module to create virtualhosts on the fly out of a cdb-database file. ... In one module I saw the following: 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); 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. In a threaded mpm, the same r-server struct is used by multiple requests simultaneously. It isn't safe to change anything in it on the fly. It is usually good enough to look up a new root directory and use apr_filepath_merge() to set the actual filename in a translate_name hook, without trying to update the server_rec. r-hostname has the requested hostname for any scripts which require this info. Take a look at mod_vhost_alias, or mod_vhost_dbd at http://dbd-modules.googlecode.com for examples. -tom-
what should be done in a vhost_db module?
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
Re: what should be done in a vhost_db module?
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 signature.asc Description: PGP signature