You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Benedict DSilva <be...@softwareag.co.in> on 2004/02/25 07:13:12 UTC

Help required on Apache from scratch...

Hi all,

 

Just wanted to know about how does the Apache HTTP Server start, and all
that it does with the modules (Initialization, Configuration etc).

 

These are some of the points I wanted to get cleared about!!

 

1. When Apache starts up what is all that it does with the Modules 

   i.e How does it form its linked list, and maintain the reference.

2. When ever a request is sent to Apache server, then how does it process
it?

      2.1 Does it map the request to each and every module handler in the
List?

      2.2 How are all the phases then handled? Is it that for every phase of
the request(URI translation, auth, atho....etc)  

          all the modules actually consulted whether they can handle it?

 

Overall just wanted to know the working of the Apache Web Server from
Scratch.

 

Awaiting for a helping hand!

 

Thanks in Advance,

 

Warm Regards,

--BENNY

 


Re: Apache 2 module hook priorities, was: Help required on Apache from scratch...

Posted by Henri Gomez <hg...@apache.org>.
Glenn Nielsen wrote:

> On Wed, Feb 25, 2004 at 04:40:32PM +0100, Henri Gomez wrote:
> 
>>Bill Stoddard wrote:
>>
>>
>>>Benedict DSilva wrote:
>>>
>>>
>>>>Hi all,
>>>>Just wanted to know about how does the Apache HTTP Server start, and 
>>>>all that it does with the modules (Initialization, Configuration etc).
>>>
>>>
>>>Explaining how Apache HTTPD works to the degree of detail you are 
>>>looking for is a rather tall request to answer in an email. My 
>>>suggestion is to pick up a copy of Ryan Bloom's Complete Reference to 
>>>Apache 2.0 then read the code.
>>
>>Did there is a book for modules writers ?
>>
>>I'm working on jk2 connector (mod_jk2) and looking for some
>>nasty problem (mostly conflict between jk2 and others modules).
>>
>>Help welcomed ...
> 
> 
> Henri,
> 
> Getting the priority set correctly for hooks in JK2 is sticky.
> You might take a look at what I did setting hook priority in
> mod_jk 1.2 so that it would work correctly with mod_dir. My
> cvs commit messages might be helpful from 
> jakarta-tomcat-connectors/jk/native/apache-2.0/mod_jk.c .
> 
> Here is the page the docs how hook priority works:
> 
> http://httpd.apache.org/docs-2.0/developer/hooks.html
> 
> It all comes down to carefully reviewing the hook priority of other
> modules and how those modules interact with JK2. Then setting the
> hook priorities in JK2.

Well I read jk 1.2.x and 2.0.x and see no differences :

jk :

static void jk_register_hooks(apr_pool_t *p)
{
     ap_hook_handler(jk_handler,NULL,NULL,APR_HOOK_MIDDLE);
     ap_hook_post_config(jk_post_config,NULL,NULL,APR_HOOK_MIDDLE);
     ap_hook_child_init(jk_child_init,NULL,NULL,APR_HOOK_MIDDLE);
     ap_hook_translate_name(jk_translate,NULL,NULL,APR_HOOK_MIDDLE);
#if (MODULE_MAGIC_NUMBER_MAJOR > 20010808)
     ap_hook_map_to_storage(jk_map_to_storage,NULL,NULL,APR_HOOK_MIDDLE);
#endif
}


jk2 :

static void jk2_register_hooks(apr_pool_t *p)
{
     ap_hook_handler(jk2_handler, NULL, NULL, APR_HOOK_MIDDLE);
     ap_hook_post_config(jk2_post_config,NULL,NULL,APR_HOOK_MIDDLE);
     /* Force the mpm to run before us and set the scoreboard image */
     ap_hook_child_init(jk2_child_init,NULL,NULL,APR_HOOK_LAST);
     ap_hook_translate_name(jk2_translate,NULL,NULL,APR_HOOK_FIRST); /* 
use APR_HOOK_MIDDLE instead ? */
     ap_hook_map_to_storage(jk2_map_to_storage, NULL, NULL, 
APR_HOOK_MIDDLE);
}


The registering is very similar to me ...

I see in CVS that sometime in the past there was in jk :

static void jk_register_hooks(apr_pool_t *p)
  {  {
      ap_hook_handler(jk_handler, NULL, NULL, APR_HOOK_MIDDLE);      /* 
Make sure mod_alias runs before mod_jk to make sure that
           Alias's are mapped before mod_jk tries to process the request */
        static const char * const aszPre[] = { "mod_alias.c", NULL };

        /* Make sure mod_dir runs after mod_jk so that a
           DirectoryIndex index.jsp works */
        static const char * const aszPost[] = { "mod_dir.c", NULL };

        ap_hook_handler(jk_handler,aszPre,aszPost,APR_HOOK_MIDDLE);
      ap_hook_post_config(jk_post_config,NULL,NULL,APR_HOOK_MIDDLE); 
   ap_hook_post_config(jk_post_config,NULL,NULL,APR_HOOK_MIDDLE);
      ap_hook_child_init(jk_child_init,NULL,NULL,APR_HOOK_MIDDLE); 
ap_hook_child_init(jk_child_init,NULL,NULL,APR_HOOK_MIDDLE);
      ap_hook_translate_name(jk_translate,NULL,NULL,APR_HOOK_FIRST); 
   ap_hook_translate_name(jk_translate,aszPre,aszPost,APR_HOOK_MIDDLE);
  #if (MODULE_MAGIC_NUMBER_MAJOR > 20010808)  #if 
(MODULE_MAGIC_NUMBER_MAJOR > 20010808)
      ap_hook_map_to_storage(jk_map_to_storage, NULL, NULL, 
APR_HOOK_MIDDLE); 
ap_hook_map_to_storage(jk_map_to_storage,aszPre,aszPost,APR_HOOK_MIDDLE);
  #endif  #endif
  }  }


Need advices here ...



Re: Apache 2 module hook priorities, was: Help required on Apache from scratch...

Posted by Glenn Nielsen <gl...@mail.more.net>.
Henri,

Perhaps we should bounce these last two messages to tomcat-dev
and continue the discussion there.

Resolving this problem will require a great deal of painstaking
work.  Setting up test conditions to test mod_jk 1.2/2 interaction
with other core apache modules and commonly used ones like mod_dav.
Once all the test conditions are setup then we will have to review
the hook priority for these modules and try to determine the best
hook settings for mod_jk or where we need to add code to handle exceptions
in mod_jk.  Then test again until all of our test conditions pass.

Regards,

Glenn

On Wed, Feb 25, 2004 at 06:12:23PM +0100, Henri Gomez wrote:
> 
> >Henri,
> >
> >Getting the priority set correctly for hooks in JK2 is sticky.
> >You might take a look at what I did setting hook priority in
> >mod_jk 1.2 so that it would work correctly with mod_dir. My
> >cvs commit messages might be helpful from 
> >jakarta-tomcat-connectors/jk/native/apache-2.0/mod_jk.c .
> >
> >Here is the page the docs how hook priority works:
> >
> >http://httpd.apache.org/docs-2.0/developer/hooks.html
> >
> >It all comes down to carefully reviewing the hook priority of other
> >modules and how those modules interact with JK2. Then setting the
> >hook priorities in JK2.
> 
> It seems we should add more code in jk2_map_to_storage(...)
> 
> Here's what you put in jk....
> 
> 
> Correct ?
> 
>  if(!r->proxyreq && !apr_table_get(r->notes, JK_WORKER_ID)) {
>            jk_server_conf_t *conf =
>                (jk_server_conf_t 
> *)ap_get_module_config(r->server->module_config,
>                                                         &jk_module);
> 
>            if(conf) {
>                char *worker;
>                if( (r->handler != NULL ) &&
>                    (! strcmp( r->handler, JK_HANDLER ) )) {
>                    /* Somebody already set the handler, probably manual 
> config
>                     * or "native" configuration, no need for extra 
> overhead
>                     */
>                    jk_log(conf->log, JK_LOG_DEBUG,
>                           "Manually mapped, no need to call 
> uri_to_worker\n");
>                    return DECLINED;
>                }
>                worker = map_uri_to_worker(conf->uw_map, r->uri, 
> conf->log);
> 
>                if(worker) {
>                    r->handler=apr_pstrdup(r->pool,JK_HANDLER);
>                    apr_table_setn(r->notes, JK_WORKER_ID, worker);
> 
>                    /* This could be a sub-request, possibly from 
> mod_dir */
>                    if(r->main)
>                        apr_table_setn(r->main->notes, JK_WORKER_ID, 
> worker);
> 
>                }
>            }
>        }
----------------------------------------------------------------------
Glenn Nielsen             glenn@more.net | /* Spelin donut madder    |
MOREnet System Programming               |  * if iz ina coment.      |
Missouri Research and Education Network  |  */                       |
----------------------------------------------------------------------

Re: Apache 2 module hook priorities, was: Help required on Apache from scratch...

Posted by Glenn Nielsen <gl...@mail.more.net>.
Henri,

Perhaps we should bounce these last two messages to tomcat-dev
and continue the discussion there.

Resolving this problem will require a great deal of painstaking
work.  Setting up test conditions to test mod_jk 1.2/2 interaction
with other core apache modules and commonly used ones like mod_dav.
Once all the test conditions are setup then we will have to review
the hook priority for these modules and try to determine the best
hook settings for mod_jk or where we need to add code to handle exceptions
in mod_jk.  Then test again until all of our test conditions pass.

Regards,

Glenn

On Wed, Feb 25, 2004 at 06:12:23PM +0100, Henri Gomez wrote:
> 
> >Henri,
> >
> >Getting the priority set correctly for hooks in JK2 is sticky.
> >You might take a look at what I did setting hook priority in
> >mod_jk 1.2 so that it would work correctly with mod_dir. My
> >cvs commit messages might be helpful from 
> >jakarta-tomcat-connectors/jk/native/apache-2.0/mod_jk.c .
> >
> >Here is the page the docs how hook priority works:
> >
> >http://httpd.apache.org/docs-2.0/developer/hooks.html
> >
> >It all comes down to carefully reviewing the hook priority of other
> >modules and how those modules interact with JK2. Then setting the
> >hook priorities in JK2.
> 
> It seems we should add more code in jk2_map_to_storage(...)
> 
> Here's what you put in jk....
> 
> 
> Correct ?
> 
>  if(!r->proxyreq && !apr_table_get(r->notes, JK_WORKER_ID)) {
>            jk_server_conf_t *conf =
>                (jk_server_conf_t 
> *)ap_get_module_config(r->server->module_config,
>                                                         &jk_module);
> 
>            if(conf) {
>                char *worker;
>                if( (r->handler != NULL ) &&
>                    (! strcmp( r->handler, JK_HANDLER ) )) {
>                    /* Somebody already set the handler, probably manual 
> config
>                     * or "native" configuration, no need for extra 
> overhead
>                     */
>                    jk_log(conf->log, JK_LOG_DEBUG,
>                           "Manually mapped, no need to call 
> uri_to_worker\n");
>                    return DECLINED;
>                }
>                worker = map_uri_to_worker(conf->uw_map, r->uri, 
> conf->log);
> 
>                if(worker) {
>                    r->handler=apr_pstrdup(r->pool,JK_HANDLER);
>                    apr_table_setn(r->notes, JK_WORKER_ID, worker);
> 
>                    /* This could be a sub-request, possibly from 
> mod_dir */
>                    if(r->main)
>                        apr_table_setn(r->main->notes, JK_WORKER_ID, 
> worker);
> 
>                }
>            }
>        }
----------------------------------------------------------------------
Glenn Nielsen             glenn@more.net | /* Spelin donut madder    |
MOREnet System Programming               |  * if iz ina coment.      |
Missouri Research and Education Network  |  */                       |
----------------------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: Apache 2 module hook priorities, was: Help required on Apache from scratch...

Posted by Henri Gomez <hg...@apache.org>.
> Henri,
> 
> Getting the priority set correctly for hooks in JK2 is sticky.
> You might take a look at what I did setting hook priority in
> mod_jk 1.2 so that it would work correctly with mod_dir. My
> cvs commit messages might be helpful from 
> jakarta-tomcat-connectors/jk/native/apache-2.0/mod_jk.c .
> 
> Here is the page the docs how hook priority works:
> 
> http://httpd.apache.org/docs-2.0/developer/hooks.html
> 
> It all comes down to carefully reviewing the hook priority of other
> modules and how those modules interact with JK2. Then setting the
> hook priorities in JK2.

It seems we should add more code in jk2_map_to_storage(...)

Here's what you put in jk....


Correct ?

  if(!r->proxyreq && !apr_table_get(r->notes, JK_WORKER_ID)) {
            jk_server_conf_t *conf =
                (jk_server_conf_t 
*)ap_get_module_config(r->server->module_config,
                                                         &jk_module);

            if(conf) {
                char *worker;
                if( (r->handler != NULL ) &&
                    (! strcmp( r->handler, JK_HANDLER ) )) {
                    /* Somebody already set the handler, probably manual 
config
                     * or "native" configuration, no need for extra 
overhead
                     */
                    jk_log(conf->log, JK_LOG_DEBUG,
                           "Manually mapped, no need to call 
uri_to_worker\n");
                    return DECLINED;
                }
                worker = map_uri_to_worker(conf->uw_map, r->uri, 
conf->log);

                if(worker) {
                    r->handler=apr_pstrdup(r->pool,JK_HANDLER);
                    apr_table_setn(r->notes, JK_WORKER_ID, worker);

                    /* This could be a sub-request, possibly from 
mod_dir */
                    if(r->main)
                        apr_table_setn(r->main->notes, JK_WORKER_ID, 
worker);

                }
            }
        }


Apache 2 module hook priorities, was: Help required on Apache from scratch...

Posted by Glenn Nielsen <gl...@mail.more.net>.
On Wed, Feb 25, 2004 at 04:40:32PM +0100, Henri Gomez wrote:
> Bill Stoddard wrote:
> 
> >Benedict DSilva wrote:
> >
> >>Hi all,
> >>Just wanted to know about how does the Apache HTTP Server start, and 
> >>all that it does with the modules (Initialization, Configuration etc).
> >
> >
> >Explaining how Apache HTTPD works to the degree of detail you are 
> >looking for is a rather tall request to answer in an email. My 
> >suggestion is to pick up a copy of Ryan Bloom's Complete Reference to 
> >Apache 2.0 then read the code.
> 
> Did there is a book for modules writers ?
> 
> I'm working on jk2 connector (mod_jk2) and looking for some
> nasty problem (mostly conflict between jk2 and others modules).
> 
> Help welcomed ...

Henri,

Getting the priority set correctly for hooks in JK2 is sticky.
You might take a look at what I did setting hook priority in
mod_jk 1.2 so that it would work correctly with mod_dir. My
cvs commit messages might be helpful from 
jakarta-tomcat-connectors/jk/native/apache-2.0/mod_jk.c .

Here is the page the docs how hook priority works:

http://httpd.apache.org/docs-2.0/developer/hooks.html

It all comes down to carefully reviewing the hook priority of other
modules and how those modules interact with JK2. Then setting the
hook priorities in JK2.

Regards,

Glenn

----------------------------------------------------------------------
Glenn Nielsen             glenn@more.net | /* Spelin donut madder    |
MOREnet System Programming               |  * if iz ina coment.      |
Missouri Research and Education Network  |  */                       |
----------------------------------------------------------------------

Re: Help required on Apache from scratch...

Posted by Henri Gomez <hg...@apache.org>.
Bill Stoddard wrote:

> Benedict DSilva wrote:
> 
>> Hi all,
>> Just wanted to know about how does the Apache HTTP Server start, and 
>> all that it does with the modules (Initialization, Configuration etc).
> 
> 
> Explaining how Apache HTTPD works to the degree of detail you are 
> looking for is a rather tall request to answer in an email. My 
> suggestion is to pick up a copy of Ryan Bloom's Complete Reference to 
> Apache 2.0 then read the code.

Did there is a book for modules writers ?

I'm working on jk2 connector (mod_jk2) and looking for some
nasty problem (mostly conflict between jk2 and others modules).

Help welcomed ...

Re: Help required on Apache from scratch...

Posted by Henri Gomez <hg...@apache.org>.
Gerardo Reynaga wrote:
> Hi Benedict,
> 
> I found a good reference and documentation, see URL below. I believe this
> will be useful for you. There's a document called The Apache Modeling
> Project. 
> An html version of it can be found at: apache.hpi.uni-potsdam.de/document/

Excellent works, congratulations

Re: Help required on Apache from scratch...

Posted by Gerardo Reynaga <ge...@scs.carleton.ca>.
Hi Benedict,

I found a good reference and documentation, see URL below. I believe this
will be useful for you. There's a document called The Apache Modeling
Project. 
An html version of it can be found at: apache.hpi.uni-potsdam.de/document/

  Apache Modeling Portal
  http://apache.hpi.uni-potsdam.de/

Cheers,
Gerardo

On Wed, 25 Feb 2004, Bill Stoddard wrote:

> Benedict DSilva wrote:
> 
> > Hi all,
> > Just wanted to know about how does the Apache HTTP Server start, and all 
> > that it does with the modules (Initialization, Configuration etc).
> 
> Explaining how Apache HTTPD works to the degree of detail you are looking for is a rather tall request to 
> answer in an email. My suggestion is to pick up a copy of Ryan Bloom's Complete Reference to Apache 2.0 then 
> read the code.
> 
> Bill
> 
> 


Re: Help required on Apache from scratch...

Posted by Bill Stoddard <bi...@wstoddard.com>.
Benedict DSilva wrote:

> Hi all,
> Just wanted to know about how does the Apache HTTP Server start, and all 
> that it does with the modules (Initialization, Configuration etc).

Explaining how Apache HTTPD works to the degree of detail you are looking for is a rather tall request to 
answer in an email. My suggestion is to pick up a copy of Ryan Bloom's Complete Reference to Apache 2.0 then 
read the code.

Bill



RE: Help required on Apache from scratch...

Posted by Sung Kim <hu...@ucsc.edu>.
Hi, 

Apache module uses hooks (function pointers) to invoke proper modules for
each request, and there are several hook categories such as initialization,
log, auth, and main handler. I recommend reading mod_example.c (in
modules/experimental) and compiling it with your Apache. I'm sure that will
answer most of your questions.

- Sung
________________________________________
From: Benedict DSilva [mailto:benedict.dsilva@softwareag.co.in] 
Sent: Tuesday, February 24, 2004 10:13 PM
To: dev@httpd.apache.org
Subject: Help required on Apache from scratch...

Hi all,
 
Just wanted to know about how does the Apache HTTP Server start, and all
that it does with the modules (Initialization, Configuration etc).
 
These are some of the points I wanted to get cleared about!!
 
1. When Apache starts up what is all that it does with the Modules 
   i.e How does it form its linked list, and maintain the reference.
2. When ever a request is sent to Apache server, then how does it process
it?
      2.1 Does it map the request to each and every module handler in the
List?
      2.2 How are all the phases then handled? Is it that for every phase of
the request(URI translation, auth, atho....etc)  
          all the modules actually consulted whether they can handle it?
 
Overall just wanted to know the working of the Apache Web Server from
Scratch.
 
Awaiting for a helping hand!
 
Thanks in Advance,
 
Warm Regards,
--BENNY