tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hgo...@apache.org
Subject cvs commit: jakarta-tomcat-connectors/jk/native2/include jk_worker.h
Date Fri, 27 Feb 2004 08:34:18 GMT
hgomez      2004/02/27 00:34:18

  Modified:    jk/native2/server/apache2 mod_jk2.c
               jk/native2/common jk_worker_lb.c
               jk/native2/include jk_worker.h
  Log:
  Fix problem with ErrorDocument and Apache 2.0.
  
  By default now, WE DON'T touch the headers
  
  Revision  Changes    Path
  1.68      +12 -5     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.67
  retrieving revision 1.68
  diff -u -r1.67 -r1.68
  --- mod_jk2.c	24 Feb 2004 08:44:42 -0000	1.67
  +++ mod_jk2.c	27 Feb 2004 08:34:18 -0000	1.68
  @@ -22,7 +22,7 @@
    ***************************************************************************/
   
   /*
  - * mod_jk: keeps all servlet/jakarta related ramblings together.
  + * mod_jk2: keeps all servlet/jakarta related ramblings together.
    */
   
   
  @@ -697,7 +697,7 @@
           env->l->jkLog(env, env->l, JK_LOG_ERROR, 
                         "mod_jk.handle() No worker for %s\n", r->uri); 
           workerEnv->globalEnv->releaseEnv( workerEnv->globalEnv, env );
  -        return 500;
  +        return HTTP_INTERNAL_SERVER_ERROR;
       }
   
       if( uriEnv->mbean->debug > 0 )
  @@ -752,9 +752,16 @@
       }
   
       env->l->jkLog(env, env->l, JK_LOG_ERROR,
  -                  "mod_jk.handler() Error connecting to tomcat %d\n", rc);
  +                  "mod_jk.handler() Error connecting to tomcat %d, status %d\n", rc, s->status);
  +                  
       workerEnv->globalEnv->releaseEnv( workerEnv->globalEnv, env );
  -    return 500;
  +
  +    /* In case of error, if service() set a status code, send it back */
  +    /* Else fallback to HTTP_INTERNAL_SERVER_ERROR (500). */
  +    if (s->status != 0)
  +        return s->status;
  +    else
  +        return HTTP_INTERNAL_SERVER_ERROR;  
   }
   
   /** Use the internal mod_jk mappings to find if this is a request for
  
  
  
  1.37      +24 -16    jakarta-tomcat-connectors/jk/native2/common/jk_worker_lb.c
  
  Index: jk_worker_lb.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_worker_lb.c,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- jk_worker_lb.c	24 Feb 2004 08:44:40 -0000	1.36
  +++ jk_worker_lb.c	27 Feb 2004 08:34:18 -0000	1.37
  @@ -326,7 +326,7 @@
       }
   
       /* Initialize here the recovery POST buffer */
  -	s->reco_buf = jk2_msg_ajp_create( env, s->pool, 0);
  +    s->reco_buf = jk2_msg_ajp_create( env, s->pool, 0);
       s->reco_status = RECO_INITED;
       
       while(1) {
  @@ -356,17 +356,21 @@
                   s->status=lb->noWorkerCode; /* SERVICE_UNAVAILABLE is the default
*/
               }
   
  -            if( s->status == 302 ) {
  -                s->headers_out->put(env, s->headers_out,
  -                                    "Location", lb->noWorkerMsg, NULL);
  -                s->head(env, s );
  -            } else {
  -                s->headers_out->put(env, s->headers_out,
  -                                    "Content-Type", "text/html", NULL);
  -                s->head(env, s );
  -                s->jkprintf(env, s, lb->noWorkerMsg );
  -            }
  -            
  +            /* Don't touch headers if noErrorHeader set to TRUE, ie ErrorDocument in Apache
via mod_alias */
  +            if (! lb->noErrorHeader) {
  +                /* XXX: I didn't understand the 302, since s->status is lb->hwBalanceErr
or lb->noWorkerCode */
  +                /* Both could be set in workers2.properties so ..... */ 
  +                if( s->status == 302 ) {
  +                    s->headers_out->put(env, s->headers_out,
  +                                        "Location", lb->noWorkerMsg, NULL);
  +                    s->head(env, s );
  +                } else {
  +                    s->headers_out->put(env, s->headers_out,
  +                                        "Content-Type", "text/html", NULL);
  +                    s->head(env, s );
  +                    s->jkprintf(env, s, lb->noWorkerMsg );
  +                }
  +            }            
               s->afterRequest( env, s);
               lb_priv->error_time = time(NULL);
               return JK_ERR;
  @@ -473,10 +477,10 @@
   
   static char *jk2_worker_lb_multiValueInfo[]={"worker", NULL };
   static char *jk2_worker_lb_setAttributeInfo[]={"attempts", "stickySession", "recovery",
"timeout",
  -                                               "hwBalanceErr", "noWorkerMsg", "noWorkerCode",
"worker", NULL };
  +                                               "hwBalanceErr", "noErrorHeader", "noWorkerMsg",
"noWorkerCode", "worker", NULL };
   
   static char *jk2_worker_lb_getAttributeInfo[]={"attempts", "stickySession", "recovery",
"timeout",
  -                                               "hwBalanceErr", "noWorkerMsg", "noWorkerCode",
"workers", NULL };
  +                                               "hwBalanceErr", "noErrorHeader", "noWorkerMsg",
"noWorkerCode", "workers", NULL };
   
   
   static void * JK_METHOD jk2_lb_getAttribute(jk_env_t *env, jk_bean_t *mbean, 
  @@ -494,6 +498,8 @@
           return jk2_env_itoa( env, lb->noWorkerCode);
       } else if( strcmp( name, "hwBalanceErr") == 0 ) {
           return jk2_env_itoa( env, lb->hwBalanceErr);
  +    } else if( strcmp( name, "noErrorHeader") == 0 ) {
  +        return jk2_env_itoa( env, lb->noErrorHeader);
       } else if( strcmp( name, "timeout") == 0 ) {
           return jk2_env_itoa( env, lb_priv->timeout);
       } else if( strcmp( name, "recovery") == 0 ) {
  @@ -534,6 +540,8 @@
           lb->noWorkerCode=atoi( value );
       } else if( strcmp( name, "hwBalanceErr") == 0 ) {
           lb->hwBalanceErr=atoi( value );
  +    } else if( strcmp( name, "noErrorHeader") == 0 ) {
  +        lb->noErrorHeader=atoi( value );
       } else if( strcmp( name, "timeout") == 0 ) {
           lb_priv->timeout=atoi( value );
       } else if( strcmp( name, "recovery") == 0 ) {
  @@ -637,10 +645,10 @@
       w->hwBalanceErr=0;
       w->noWorkerCode=503;
       w->noWorkerMsg=NO_WORKER_MSG;
  -
  +    /* Let Apache handle the error via ErrorDocument and mod_alias */
  +    w->noErrorHeader=1;
       w->workerEnv=env->getByName( env, "workerEnv" );
       w->workerEnv->addWorker( env, w->workerEnv, w );
   
       return JK_OK;
   }
  -
  
  
  
  1.35      +6 -2      jakarta-tomcat-connectors/jk/native2/include/jk_worker.h
  
  Index: jk_worker.h
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/include/jk_worker.h,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- jk_worker.h	24 Feb 2004 08:44:39 -0000	1.34
  +++ jk_worker.h	27 Feb 2004 08:34:18 -0000	1.35
  @@ -50,7 +50,6 @@
      in error state, we move to the next leve.
   */
   #define JK_LB_LEVELS 4
  -#define JK_LB_MAX_WORKERS 256
   
   /* XXX Separate this in 2 structures: jk_lb.h and jk_ajp.h.
      Using 'worker' as a generic term is confusing, the objects are very different.
  @@ -222,6 +221,11 @@
        */
       char *noWorkerMsg;
       int  noWorkerCode;
  +    
  +    /* jk2 shouldn't set headers if noErrorHeader (true by default) 
  +     * It will allow Apache 2.0 to handle correctly ErrorDocument
  +     */
  +    int  noErrorHeader;
       
       int workerCnt[JK_LB_LEVELS];
       jk_worker_t *workerTables[JK_LB_LEVELS][JK_LB_MAX_WORKERS];
  
  
  

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


Mime
View raw message