tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cost...@covalent.net
Subject RE: cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_ajp13.c
Date Wed, 26 Jun 2002 16:32:28 GMT
On Wed, 26 Jun 2002, GOMEZ Henri wrote:

> This part of code in jk 1.2/2.0 is really a spaghetti :[
> 
> I spent many times in it, and I think we should refactor it
> at least in jk2.

Yes, I already did a bit of cleanup - and we can do more.

Part of the complexity comes from the attempt to deal with both 
2-thread/blocking and 1-thread scenarios, and keep the code 
common. The 1-thread scenario is used for JNI ( and could be 
used for doors and possibly other communication mechanism ).
I personally think it's worth it, and it affects 2-3 methods
in 2 files.

As for 'recoverable' - it is more a matter of deciding when
a request can no longer be 'recovered' and implementing 
acordingly. We should remove the second field too - which
doesn't seem needed, and document the code more.

But the fact is what we're trying to do is not trivial, 
there are many use-cases that have to be taken into account,
and it's normal to have some complexity.

Costin


> >-----Original Message-----
> >From: costin@apache.org [mailto:costin@apache.org]
> >Sent: Wednesday, June 26, 2002 4:42 AM
> >To: jakarta-tomcat-connectors-cvs@apache.org
> >Subject: cvs commit: jakarta-tomcat-connectors/jk/native2/common
> >jk_worker_ajp13.c
> >
> >
> >costin      2002/06/25 19:41:39
> >
> >  Modified:    jk/native2/common jk_worker_ajp13.c
> >  Log:
> >  Another attempt to fix the 'tomcat restart' problem.
> >  
> >  send ( with either write or send() ) doesn't detect if 
> >tomcat is disconnected -
> >  only the first receive does report the error.
> >  
> >  What we do is use the 'recoverable' field to mark if tomcat 
> >has already
> >  started to process the request ( i.e. we received at least 
> >one packet -
> >  probably the HEAD, in which case the error can't be recovered ).
> >  
> >  If this is just a tomcat restart, we'll save the post body ( 
> >initial chunk ),
> >  and resend it. The logic is a bit tricky - but I think I got 
> >it right this
> >  time ( it affected the case that a POST is made just after restart )
> >  
> >  Revision  Changes    Path
> >  1.34      +17 -8     
> >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.33
> >  retrieving revision 1.34
> >  diff -u -r1.33 -r1.34
> >  --- jk_worker_ajp13.c	20 Jun 2002 18:45:01 -0000	1.33
> >  +++ jk_worker_ajp13.c	26 Jun 2002 02:41:39 -0000	1.34
> >  @@ -299,10 +299,12 @@
> >   {
> >       int err=JK_OK;
> >       int attempt;
> >  +    int has_post_body=JK_FALSE;
> >  +    jk_channel_t *channel= worker->channel;
> >   
> >       e->recoverable = JK_TRUE;
> >       s->is_recoverable_error = JK_TRUE;
> >  -    
> >  +
> >       /*
> >        * Try to send the request on a valid endpoint. If one endpoint
> >        * fails, close the channel and try again ( maybe 
> >tomcat was restarted )
> >  @@ -311,7 +313,6 @@
> >        * a load-balancing configuration 
> >        */
> >       for(attempt = 0 ; attempt < JK_RETRIES ;attempt++) {
> >  -        jk_channel_t *channel= worker->channel;
> >   
> >           if( e->sd == -1 ) {
> >               err=jk2_worker_ajp13_connect(env, e);
> >  @@ -322,6 +323,9 @@
> >                   e->worker->in_error_state=JK_TRUE;
> >                   return err;
> >               }
> >  +            if( worker->mbean->debug > 0 )
> >  +                env->l->jkLog(env, env->l, JK_LOG_INFO,
> >  +                              "ajp13.service() connecting 
> >to endpoint \n");
> >           }
> >   
> >           err=e->worker->channel->send( env, e->worker->channel,
e,
> >  @@ -332,7 +336,6 @@
> >           
> >           if (err!=JK_OK ) {
> >               /* Can't send - bad endpoint, try again */
> >  -
> >               env->l->jkLog(env, env->l, JK_LOG_ERROR,
> >                             "ajp13.service() error sending, 
> >reconnect %s %d %d %s\n",
> >                             e->worker->channelName, err, 
> >errno, strerror(errno));
> >  @@ -346,7 +349,7 @@
> >              request was sent ( we're receiving data from 
> >client, can be slow, no
> >              need to delay - we can do that in paralel. ( not 
> >very sure this is
> >              very usefull, and it brakes the protocol ) ! */
> >  -        if (s->is_chunked || s->left_bytes_to_send > 0) {
> >  +        if (has_post_body || s->is_chunked || 
> >s->left_bytes_to_send > 0) {
> >               /* 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
> >  @@ -354,6 +357,8 @@
> >                */
> >               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" );
> >  @@ -363,17 +368,20 @@
> >                   /* 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 \n");
> >  +                              "ajp13.service() Error 
> >receiving initial post %d %d %d\n", err, errno, attempt);
> >                   return JK_ERR;
> >               }
> >  +            has_post_body=JK_TRUE;
> >               err= e->worker->channel->send( env, 
> >e->worker->channel, e,
> >                                              e->post );
> >               if( err != JK_OK ) {
> >                   /* e->recoverable = JK_FALSE; */
> >  -                s->is_recoverable_error = JK_FALSE;
> >  +                /*                 s->is_recoverable_error 
> >= JK_FALSE; */
> >                   env->l->jkLog(env, env->l, JK_LOG_ERROR,
> >  -                              "ajp13.service() Error 
> >receiving initial post \n");
> >  -                return JK_ERR;
> >  +                              "ajp13.service() Error 
> >sending initial post %d %d %d\n", err, errno, attempt);
> >  +                jk2_close_endpoint(env, e);
> >  +                continue;
> >  +                /*  return JK_ERR; */
> >               }
> >           }
> >   
> >  @@ -399,6 +407,7 @@
> >                             err);
> >               jk2_close_endpoint(env, e ); 
> >          }
> >  +
> >           if( err==JK_OK )
> >               return err;
> >       }
> >  
> >  
> >  
> >
> >--
> >To unsubscribe, e-mail:   
> <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>
> 
> 



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


Mime
View raw message