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/server/apache13 mod_jk2.c
Date Fri, 13 Feb 2004 08:40:42 GMT
hgomez      2004/02/13 00:40:42

  Modified:    jk/native2/common jk_requtil.c jk_worker_lb.c jk_msg_ajp.c
                        jk_worker_ajp13.c
               jk/native2/server/apache2 mod_jk2.c
               jk/native2/include jk_msg.h jk_service.h
               jk/native2/server/aolserver nsjk2.c
               jk/native2/server/dsapi jk_dsapi_plugin.c
               jk/native2/server/isapi jk_isapi_plugin.c
               jk/native2/server/apache13 mod_jk2.c
  Log:
  Port the POST recovery in LB mode from jk.
  
  Need some tests of course
  
  Revision  Changes    Path
  1.30      +1 -1      jakarta-tomcat-connectors/jk/native2/common/jk_requtil.c
  
  Index: jk_requtil.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_requtil.c,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- jk_requtil.c	25 Sep 2003 15:23:22 -0000	1.29
  +++ jk_requtil.c	13 Feb 2004 08:40:41 -0000	1.30
  @@ -752,7 +752,7 @@
       }                  
               
       env->l->jkLog(env, env->l, JK_LOG_ERROR,
  -             "handler.marshapPostHead() - error len=%d\n", len);
  +             "handler.marshalPostHead() - error len=%d\n", len);
       return JK_ERR;	    
   }
   /* -------------------- Query decoding -------------------- */
  
  
  
  1.35      +4 -0      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.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- jk_worker_lb.c	30 Oct 2003 20:08:36 -0000	1.34
  +++ jk_worker_lb.c	13 Feb 2004 08:40:41 -0000	1.35
  @@ -365,6 +365,10 @@
               wEnv->config->ver = wEnv->shm->head->lbVer;
           }
       }
  +
  +    /* Initialize here the recovery POST buffer */
  +	s->reco_buf = jk2_msg_ajp_create( env, s->pool, 0);
  +    s->reco_status = RECO_INITED;
       
       while(1) {
           int rc;
  
  
  
  1.23      +24 -0     jakarta-tomcat-connectors/jk/native2/common/jk_msg_ajp.c
  
  Index: jk_msg_ajp.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_msg_ajp.c,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- jk_msg_ajp.c	25 Sep 2003 15:23:23 -0000	1.22
  +++ jk_msg_ajp.c	13 Feb 2004 08:40:41 -0000	1.23
  @@ -468,6 +468,29 @@
   }
   
   
  +/** 
  + * Copy the msg buf into another one, sort of clone.
  + *
  + * Returns -1 on error, else number of bytes copied
  + */
  +static int jk2_msg_ajp_copy(jk_env_t *env, jk_msg_t  *msg, jk_msg_t *dmsg)
  +{
  +	if (dmsg == NULL)
  +		return -1;
  +		
  +    if(msg->len > dmsg->maxlen ) {
  +        env->l->jkLog(env, env->l, JK_LOG_ERROR,
  +                      "msgAjp.copy(): destination buffer too small %d/%d\n",
  +                      msg->len, dmsg->maxlen);
  +        return -2;
  +    }
  +
  +	memcpy(dmsg->buf, msg->buf, msg->len);
  +	dmsg->len = msg->len;
  +	dmsg->pos = msg->pos;
  +	
  +	return dmsg->len;
  +}
   
   /** 
    * Special method. Will read data from the server and add them as
  @@ -539,6 +562,7 @@
       msg->appendMap=jk2_msg_ajp_appendMap;
   
       msg->appendFromServer=jk2_msg_ajp_appendFromServer;
  +    msg->copy=jk2_msg_ajp_copy;
   
       msg->getByte=jk2_msg_ajp_getByte;
       msg->getInt=jk2_msg_ajp_getInt;
  
  
  
  1.54      +48 -16    jakarta-tomcat-connectors/jk/native2/common/jk_worker_ajp13.c
  
  Index: jk_worker_ajp13.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_worker_ajp13.c,v
  retrieving revision 1.53
  retrieving revision 1.54
  diff -u -r1.53 -r1.54
  --- jk_worker_ajp13.c	29 Jan 2004 14:17:41 -0000	1.53
  +++ jk_worker_ajp13.c	13 Feb 2004 08:40:41 -0000	1.54
  @@ -447,28 +447,61 @@
   
          Note that chunking will continue to work - using the normal read.
       */
  -        if (has_post_body  || s->left_bytes_to_send > 0) {
  +        if (has_post_body  || s->left_bytes_to_send > 0 || s->reco_status == RECO_FILLED)
{
               /* We never sent any POST data and we check it we have to send at
                * least of block of data (max 8k). These data will be kept in reply
                * for resend if the remote Tomcat is down, a fact we will learn only
                * doing a read (not yet) 
                */
  -            if( attempt==0 )
  -                err=jk2_serialize_postHead( env, e->post, s, e );
  -            else
  -                err=JK_OK; /* We already have the initial body chunk */
  -            
  -            if( e->worker->mbean->debug > 10 )
  -                e->request->dump( env, e->request, "Post head" );
               
  -            if (err != JK_OK ) {
  -                /* the browser stop sending data, no need to recover */
  -                /* e->recoverable = JK_FALSE; */
  -                s->is_recoverable_error = JK_FALSE;
  -                env->l->jkLog(env, env->l, JK_LOG_ERROR,
  -                              "ajp13.service() Error receiving initial post %d %d %d\n",
err, errno, attempt);
  -                return JK_ERR;
  +            /* If we have the service recovery buffer FILLED and we're in first attempt
*/
  +            /* recopy the recovery buffer in post instead of reading it from client */
  +            if ( s->reco_status == RECO_FILLED && (attempt==0) ) {
  +		    	/* Get in post buf the previously saved POST */
  +		    	
  +		    	if (s->reco_buf->copy(env, s->reco_buf, e->post) < 0) {
  +		                s->is_recoverable_error = JK_FALSE;
  +		                env->l->jkLog(env, env->l, JK_LOG_ERROR,
  +		                              "ajp13.service() can't use the LB recovery buffer, aborting\n");
  +	                return JK_ERR;
  +		    	}		    	
  +
  +                env->l->jkLog(env, env->l, JK_LOG_DEBUG,
  +                              "ajp13.service() using the LB recovery buffer\n");
               }
  +            else
  +            {
  +	            if( attempt==0 )
  +	                err=jk2_serialize_postHead( env, e->post, s, e );
  +	            else
  +	                err=JK_OK; /* We already have the initial body chunk */
  +	            
  +	            if( e->worker->mbean->debug > 10 )
  +	                e->request->dump( env, e->request, "Post head" );
  +	            
  +	            if (err != JK_OK ) {
  +	                /* the browser stop sending data, no need to recover */
  +	                /* e->recoverable = JK_FALSE; */
  +	                s->is_recoverable_error = JK_FALSE;
  +	                env->l->jkLog(env, env->l, JK_LOG_ERROR,
  +	                              "ajp13.service() Error receiving initial post %d %d %d\n",
err, errno, attempt);
  +	                return JK_ERR;
  +	            }
  +
  +				/* If a recovery buffer exist (LB mode), save here the post buf */
  +				if (s->reco_status == RECO_INITED) {
  +			    	/* Save the post for recovery if needed */
  +			    	if (e->post->copy(env, e->post, s->reco_buf) < 0) {
  +		                s->is_recoverable_error = JK_FALSE;
  +		                env->l->jkLog(env, env->l, JK_LOG_ERROR,
  +		                              "ajp13.service() can't save the LB recovery buffer, aborting\n");
  +		                return JK_ERR;
  +			    	}
  +			    	else	
  +			    		s->reco_status = RECO_FILLED;
  +				}
  +			}
  +			
               has_post_body=JK_TRUE;
               err= e->worker->channel->send( env, e->worker->channel, e,
                                              e->post );
  @@ -482,7 +515,6 @@
                   /*  return JK_ERR; */
               }
           }
  -
           
           err = e->worker->workerEnv->processCallbacks(env, e->worker->workerEnv,
                                                        e, s);
  
  
  
  1.66      +5 -2      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.65
  retrieving revision 1.66
  diff -u -r1.65 -r1.66
  --- mod_jk2.c	9 Feb 2004 12:01:22 -0000	1.65
  +++ mod_jk2.c	13 Feb 2004 08:40:42 -0000	1.66
  @@ -760,9 +760,12 @@
       
       /* XXX we should reuse the request itself !!! */
       jk2_service_apache2_init( env, s );
  -    
  +
       s->pool = rPool;
       s->init( env, s, worker, r );
  +    
  +    /* reset the reco_status, will be set to INITED in LB mode */
  +    s->reco_status = RECO_NONE;
       
       s->is_recoverable_error = JK_FALSE;
       s->uriEnv = uriEnv; 
  
  
  
  1.15      +9 -0      jakarta-tomcat-connectors/jk/native2/include/jk_msg.h
  
  Index: jk_msg.h
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/include/jk_msg.h,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- jk_msg.h	24 Sep 2002 22:45:18 -0000	1.14
  +++ jk_msg.h	13 Feb 2004 08:40:42 -0000	1.15
  @@ -196,6 +196,15 @@
                               struct jk_endpoint  *ae,
                               int            len );
   
  +    /** 
  +     * Clone the msg buf into another one, sort of clone.
  +     *
  +     * Returns -1 on error, else number of bytes copied
  +     */
  +    int (*copy)(struct jk_env *env,
  +                 struct jk_msg *_this,
  +                 struct jk_msg *dst);
  +
       void *_privatePtr;
       
       /* Temporary, don't use */
  
  
  
  1.21      +21 -1     jakarta-tomcat-connectors/jk/native2/include/jk_service.h
  
  Index: jk_service.h
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/include/jk_service.h,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- jk_service.h	30 Oct 2003 20:11:33 -0000	1.20
  +++ jk_service.h	13 Feb 2004 08:40:42 -0000	1.21
  @@ -126,6 +126,20 @@
   #define SC_M_MKACTIVITY         (unsigned char)27
   
   
  +/*
  + * RECOVERY STATUS
  + *
  + * The recovery buffer status is RECO_NONE unless we're using a LB service.
  + * In such case, the status is RECO_INITED. 
  + * The first real worker will detect this special status and will fill the 
  + * recovery buffer with initial POST data. In case of failure, the next worker
  + * will use this recovery buffer to feed tomcat with the saved initial POST data.
  + */
  +
  +#define RECO_NONE	0x00
  +#define RECO_INITED	0x01
  +#define RECO_FILLED	0x02
  +
       
   /*
    * The web server service 'class'.  An instance of this class is created
  @@ -276,6 +290,12 @@
       int outSize;
       char *outBuf;
       apr_time_t startTime;
  +
  +    /*
  +     * Area to get POST data for fail-over recovery in POST (used in LB mode)
  +     */
  +    struct jk_msg *reco_buf; 
  +    int		       reco_status;
       
       /** printf style output. Formats in the tmp buf, then calls write
        */
  
  
  
  1.3       +4 -0      jakarta-tomcat-connectors/jk/native2/server/aolserver/nsjk2.c
  
  Index: nsjk2.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/server/aolserver/nsjk2.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- nsjk2.c	9 Jun 2003 19:46:06 -0000	1.2
  +++ nsjk2.c	13 Feb 2004 08:40:42 -0000	1.3
  @@ -286,6 +286,10 @@
       
       s->pool = rPool;
       s->init( env, s, worker, conn );
  +
  +    /* reset the reco_status, will be set to INITED in LB mode */
  +    s->reco_status = RECO_NONE;
  +    
       s->is_recoverable_error = JK_FALSE;
       s->uriEnv = uriEnv; 
       rc = worker->service(env, worker, s);    
  
  
  
  1.5       +4 -1      jakarta-tomcat-connectors/jk/native2/server/dsapi/jk_dsapi_plugin.c
  
  Index: jk_dsapi_plugin.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/server/dsapi/jk_dsapi_plugin.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- jk_dsapi_plugin.c	29 Jan 2004 16:23:50 -0000	1.4
  +++ jk_dsapi_plugin.c	13 Feb 2004 08:40:42 -0000	1.5
  @@ -974,6 +974,9 @@
   
   			jk2_requtil_initRequest(env, &s);
   
  +		    /* reset the reco_status, will be set to INITED in LB mode */
  +    		s.reco_status 			= RECO_NONE;
  +    
   			s.pool					= rPool;
   			s.is_recoverable_error	= JK_FALSE;
   			s.response_started		= JK_FALSE;
  
  
  
  1.58      +5 -1      jakarta-tomcat-connectors/jk/native2/server/isapi/jk_isapi_plugin.c
  
  Index: jk_isapi_plugin.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/server/isapi/jk_isapi_plugin.c,v
  retrieving revision 1.57
  retrieving revision 1.58
  diff -u -r1.57 -r1.58
  --- jk_isapi_plugin.c	6 Feb 2003 23:34:45 -0000	1.57
  +++ jk_isapi_plugin.c	13 Feb 2004 08:40:42 -0000	1.58
  @@ -503,6 +503,10 @@
   
       jk2_service_iis_init( env, s );
       s->pool = rPool;
  +
  +    /* reset the reco_status, will be set to INITED in LB mode */
  +    s->reco_status = RECO_NONE;
  +    
       s->is_recoverable_error = JK_FALSE;
       s->response_started = JK_FALSE;
       s->content_read = 0;
  
  
  
  1.30      +4 -1      jakarta-tomcat-connectors/jk/native2/server/apache13/mod_jk2.c
  
  Index: mod_jk2.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/server/apache13/mod_jk2.c,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- mod_jk2.c	10 Nov 2003 11:05:33 -0000	1.29
  +++ mod_jk2.c	13 Feb 2004 08:40:42 -0000	1.30
  @@ -569,6 +569,9 @@
           s->pool = rPool;
           s->init( env, s, worker, r );
           
  +	    /* reset the reco_status, will be set to INITED in LB mode */
  +	    s->reco_status = RECO_NONE;
  +	    
           s->is_recoverable_error = JK_FALSE;
           s->uriEnv = uriEnv;
   
  
  
  

---------------------------------------------------------------------
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