You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by "milosp@yu.net" <mi...@yu.net> on 2006/01/11 17:26:41 UTC

Creating independent server (server_rec) instance in module

Hi,

The point of this post is that currently it is not possible to create
a module that can implement new server_record, since some major
functions are not available. On contrary I can implement
hook_process_connection, but I'm unable to create new server instance  
with full per_dir_config and server_config .

I've tried to make independent server record instance.
In order to do this, I have to call :
static server_rec * init_server_config(process_rec *process,apr_poo_t *p)
(server/config.c - both 2.0.x and 2.2.x httpd versions)

The main functions called inside init_server_config function is:
static ap_conf_vector_t *create_server_config(apr_pool_t *,server_rec *)
and
static ap_conf_vector_t *create_default_per_dir_config(p);


I can make a local copy of create_server_config and init_server_config,
still I have to patch config.c in order to retreive total_modules  
static variable (from config.c). With patch it's not a module any more.

With static int total_modules (from config.c) I can make my own
implementation of create_default_per_dir_config and create_server_config.


I suggest that this patch shuold be applied for server/config.c
---------------------------------------------------------------------------------------------------------
--- VANILLA/httpd-2.0.55/server/config.c 2005-03-29 10:44:31.000000000 +0200
+++ httpd-2.0.55/server/config.c        2006-01-11 18:12:25.000000000 +0100
@@ -168,6 +168,10 @@
  */
 static int total_modules = 0;
 
+AP_DECLARE(int) ap_get_total_modules() {
+return total_modules;
+}
+
 /* dynamic_modules is the number of modules that have been added
  * after the pre-loaded ones have been set up. It shouldn't be larger
  * than DYNAMIC_MODULE_LIMIT.
-----------------------------------------------------------------------

and this one for http_config.h
-----------------------------------------------------------------------------
--- VANILLA/httpd-2.0.55/include/http_config.h   2005-02-04 
21:21:18.000000000 +0100
+++ httpd-2.0.55/include/http_config.h  2006-01-11 18:22:02.000000000 +0100
@@ -735,6 +735,11 @@
  */
 AP_DECLARE_DATA extern module **ap_loaded_modules;
 
+/* For future use ... */
+/** Returns total_modules static varible value from config.c
+ */
+AP_DECLARE(int) ap_get_total_modules();
+
 /* For mod_so.c... */
 /** Run a single module's two create_config hooks
  *  @param p the pool to allocate from
---------------------------------------------------------------------------------

Please if do not hesitate to make better suggestion, or some
explanation why this patch should be bad, or good.

Kind Regards
-- 

Milos Prodanovic, System Engineer
----- 
YUnet International  http://www.eunet.yu
Dubrovacka 35/III,  11000 Belgrade   
Tel: +381 11 330 5678;  Fax: + 381 11 328 2760
-----
This  e-mail  is confidential and intended only for the recipient.
Unauthorized  distribution,  modification  or  disclosure  of  its
contents is prohibited. If you have received this e-mail in error,
please notify the sender by telephone  +381 11 330 5678.
-----