You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by co...@apache.org on 2002/05/16 22:54:18 UTC

cvs commit: jakarta-tomcat-connectors/jk/native2/server/apache2 mod_jk2.c jk_service_apache2.c

costin      02/05/16 13:54:18

  Modified:    jk/native2/server/apache2 mod_jk2.c jk_service_apache2.c
  Log:
  We can't call find_by_pid in init() because the scoreboard may not be initialized
  or the process may not be registered.
  
  We can't call it in service() because linux will return the pid of the
  thread, which has nothing to do with the child id ( so it won't be found
  in the scoreboard ).
  
  We need the right pid to find the childId - it used to be available in
  connection_rec. We need the childId because there's no easy way to
  allocate a slot in the jk scoreboard ( or detect a slot is no longer
  used ).
  
  The current workaround is to get the pid in init(), which is called ( hopefully )
  in the child main thread ( which is registered in the scoreboard ).
  And we find the child_num in service, when the scoreboard is supposed
  to be ok.
  
  ( we do the same for apache1.3 - since child_num is only available
  on the first connection )
  
  Revision  Changes    Path
  1.23      +4 -9      jakarta-tomcat-connectors/jk/native2/server/apache2/mod_jk2.c
  
  Index: mod_jk2.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/server/apache2/mod_jk2.c,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- mod_jk2.c	15 May 2002 19:46:46 -0000	1.22
  +++ mod_jk2.c	16 May 2002 20:54:18 -0000	1.23
  @@ -59,7 +59,7 @@
    * Description: Apache 2 plugin for Jakarta/Tomcat                         *
    * Author:      Gal Shachor <sh...@il.ibm.com>                           *
    *                 Henri Gomez <hg...@slib.fr>                               *
  - * Version:     $Revision: 1.22 $                                           *
  + * Version:     $Revision: 1.23 $                                           *
    ***************************************************************************/
   
   /*
  @@ -78,6 +78,7 @@
   #include "http_protocol.h"
   #include "http_main.h"
   #include "http_log.h"
  +#include "scoreboard.h"
   
   #include "util_script.h"
   
  @@ -324,7 +325,7 @@
           fprintf( stderr, "Create config for virtual host\n");
       } else {
           /* Default host */
  -        fprintf( stderr, "Create config for main host\n");        
  +        /*  fprintf( stderr, "Create config for main host\n");         */
       }
   
       jkb = workerEnv->globalEnv->createBean2( workerEnv->globalEnv,
  @@ -369,11 +370,6 @@
   static char * jk2_init(jk_env_t *env, apr_pool_t *pconf,
                          jk_workerEnv_t *workerEnv, server_rec *s )
   {
  -    apr_proc_t proc;
  -    
  -    proc.pid=getpid();
  -    workerEnv->childId=find_child_by_pid( & proc );
  -
       workerEnv->init(env, workerEnv );
       workerEnv->server_name   = (char *)ap_get_server_version();
       ap_add_version_component(pconf, JK_EXPOSED_VERSION);
  @@ -450,6 +446,7 @@
   
       workerEnv->parentInit( env, workerEnv);
   
  +
   /*     if(!workerEnv->was_initialized) { */
   /*         workerEnv->was_initialized = JK_OK;         */
           
  @@ -492,13 +489,11 @@
    */
   static int jk2_handler(request_rec *r)
   {   
  -    const char       *worker_name;
       jk_logger_t      *l=NULL;
       int              rc;
       jk_worker_t *worker=NULL;
       jk_endpoint_t *end = NULL;
       jk_uriEnv_t *uriEnv;
  -    jk_uriEnv_t *dirEnv;
       jk_env_t *env;
       jk_workerEnv_t *workerEnv;
   
  
  
  
  1.21      +30 -1     jakarta-tomcat-connectors/jk/native2/server/apache2/jk_service_apache2.c
  
  Index: jk_service_apache2.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/server/apache2/jk_service_apache2.c,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- jk_service_apache2.c	15 May 2002 19:46:46 -0000	1.20
  +++ jk_service_apache2.c	16 May 2002 20:54:18 -0000	1.21
  @@ -59,7 +59,7 @@
    * Description: Apache 2 plugin for Jakarta/Tomcat                         
    * Author:      Gal Shachor <sh...@il.ibm.com>                           
    *                 Henri Gomez <hg...@slib.fr>                            
  - * Version:     $Revision: 1.20 $                                           
  + * Version:     $Revision: 1.21 $                                           
    */
   
   #include "apu_compat.h"
  @@ -354,7 +354,36 @@
       /* Common initialization */
       /* XXX Probably not needed, we're duplicating */
       jk2_requtil_initRequest(env, s);
  +
  +    /* Ugly hack to get the childId - the index used in the scoreboard,
  +       which we'll use in the jk scoreboard
  +    */
  +    if( workerEnv->childId == -1 ) 
  +    {
  +        apr_proc_t proc;
       
  +        proc.pid=workerEnv->childProcessId;
  +
  +        /* detect if scoreboard exists, the method will SIGFLT
  +           since it doesn't check internally
  +        */
  +        if( r->connection->sbh==NULL ) {
  +            env->l->jkLog(env, env->l, JK_LOG_INFO, 
  +                          "service.init() No scoreboard %d\n", proc.pid);
  +            workerEnv->childId=-2;
  +        }
  +        workerEnv->childId=find_child_by_pid( & proc );
  +        /* Avoid looking again */
  +        if( workerEnv->childId == -1 ) {
  +            env->l->jkLog(env, env->l, JK_LOG_INFO, 
  +                          "service.init() Can't find child in scoreboard %d\n", proc.pid);
  +            workerEnv->childId=-2;
  +        } else {
  +            env->l->jkLog(env, env->l, JK_LOG_INFO, 
  +                          "service.init() Found child in scoreboard %d %d\n", proc.pid, workerEnv->childId);
  +        }
  +    }
  +
       s->ws_private = r;
       s->response_started = JK_FALSE;
       s->read_body_started = JK_FALSE;
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>