You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by hg...@apache.org on 2003/10/16 09:51:48 UTC

cvs commit: jakarta-tomcat-connectors/jk/native2/include jk_channel.h jk_workerEnv.h jk_worker.h

hgomez      2003/10/16 00:51:48

  Modified:    jk/native2/common jk_handler_logon.c jk_channel_un.c
                        jk_mutex.c jk_channel_apr_socket.c
                        jk_channel_socket.c jk_handler_response.c
                        jk_channel_jni.c jk_channel.c jk_worker_ajp13.c
               jk/native2/include jk_channel.h jk_workerEnv.h jk_worker.h
  Log:
  Start to port back jk cping/cpong
  
  Revision  Changes    Path
  1.22      +3 -3      jakarta-tomcat-connectors/jk/native2/common/jk_handler_logon.c
  
  Index: jk_handler_logon.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_handler_logon.c,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- jk_handler_logon.c	25 Sep 2003 15:23:23 -0000	1.21
  +++ jk_handler_logon.c	16 Oct 2003 07:51:48 -0000	1.22
  @@ -179,7 +179,7 @@
       
       if (nego == 0xFFFFFFFF) {
           env->l->jkLog(env, env->l, JK_LOG_ERROR,
  -                      "handler.log_ok()  can't get negociated data\n");
  +                      "handler.logok()  can't get negociated data\n");
           return JK_HANDLER_FATAL;
       }
       
  @@ -187,7 +187,7 @@
       
       if (! sname) {
           env->l->jkLog(env, env->l, JK_LOG_ERROR,
  -                      "handler.logon() Error getting servlet engine name\n");
  +                      "handler.logok() Error getting servlet engine name\n");
           return JK_HANDLER_FATAL;
       }
       
  
  
  
  1.17      +17 -0     jakarta-tomcat-connectors/jk/native2/common/jk_channel_un.c
  
  Index: jk_channel_un.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_channel_un.c,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- jk_channel_un.c	4 Mar 2003 23:56:37 -0000	1.16
  +++ jk_channel_un.c	16 Oct 2003 07:51:48 -0000	1.17
  @@ -238,6 +238,22 @@
       return rc;
   }
   
  +
  +/*
  + * Wait input event on socket for timeout ms
  + */
  +static int JK_METHOD jk2_channel_un_hasinput(jk_env_t *env,
  +                                             jk_channel_t *ch,
  +                                             jk_endpoint_t *endpoint,
  +										     int timeout)
  +
  +{
  +	/*
  +	 * Should implements the select/poll for UN here
  +	 */
  +	return (JK_TRUE) ;
  +}
  +
   /** connect to Tomcat (jk_open_socket)
    */
   static int JK_METHOD jk2_channel_un_open(jk_env_t *env,
  @@ -490,6 +506,7 @@
       ch->send= jk2_channel_un_send; 
       ch->open= jk2_channel_un_open; 
       ch->close= jk2_channel_un_close; 
  +    ch->hasinput= jk2_channel_un_hasinput; 
       ch->is_stream=JK_TRUE;
       ch->serverSide=JK_FALSE;
       
  
  
  
  1.6       +3 -3      jakarta-tomcat-connectors/jk/native2/common/jk_mutex.c
  
  Index: jk_mutex.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_mutex.c,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- jk_mutex.c	4 Feb 2003 07:39:58 -0000	1.5
  +++ jk_mutex.c	16 Oct 2003 07:51:48 -0000	1.6
  @@ -83,17 +83,17 @@
       switch( code ) {
       case MUTEX_LOCK: {
           if( mutex->mbean->debug > 0 )
  -            env->l->jkLog(env, env->l, JK_LOG_DEBUG, "mutex.open()\n");
  +            env->l->jkLog(env, env->l, JK_LOG_DEBUG, "mutex.lock()\n");
           return mutex->lock(env, mutex);
       }
       case MUTEX_TRYLOCK: {
           if( mutex->mbean->debug > 0 )
  -            env->l->jkLog(env, env->l, JK_LOG_DEBUG, "mutex.close()\n");
  +            env->l->jkLog(env, env->l, JK_LOG_DEBUG, "mutex.trylock()\n");
           return mutex->tryLock(env, mutex);
       }
       case MUTEX_UNLOCK: {
           if( mutex->mbean->debug > 0 )
  -            env->l->jkLog(env, env->l, JK_LOG_DEBUG, "mutex.recv()\n");
  +            env->l->jkLog(env, env->l, JK_LOG_DEBUG, "mutex.unlock()\n");
           return mutex->unLock(env, mutex);
       }
       }/* switch */
  
  
  
  1.32      +61 -1     jakarta-tomcat-connectors/jk/native2/common/jk_channel_apr_socket.c
  
  Index: jk_channel_apr_socket.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_channel_apr_socket.c,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- jk_channel_apr_socket.c	30 Sep 2003 13:42:02 -0000	1.31
  +++ jk_channel_apr_socket.c	16 Oct 2003 07:51:48 -0000	1.32
  @@ -91,6 +91,7 @@
       short port;
       int keepalive;
       int timeout;
  +    int 
   };
   
   typedef struct jk_channel_apr_private jk_channel_apr_private_t;
  @@ -111,6 +112,11 @@
                                                 jk_endpoint_t *endpoint);
   
   
  +static char *jk2_channel_apr_socket_getAttributeInfo[]={"host", "port", "keepalive", "timeout", "nodelay", "graceful",
  +	                                                    "debug", "disabled", NULL };
  +static char *jk2_channel_apr_socket_setAttributeInfo[]={"host", "port", "keepalive", "timeout", "nodelay", "graceful",
  +	                                                    "debug", "disabled", NULL };
  +
   static int JK_METHOD jk2_channel_apr_setProperty(jk_env_t *env,
                                                       jk_bean_t *mbean, 
                                                       char *name, void *valueP)
  @@ -136,6 +142,36 @@
       return JK_OK;
   }
   
  +static void * JK_METHOD jk2_channel_apr_socket_getAttribute(jk_env_t *env, jk_bean_t *bean,
  +                                                            char *name )
  +{
  +    jk_channel_t *ch=(jk_channel_t *)bean->object;
  +    jk_channel_socket_private_t *socketInfo=
  +        (jk_channel_socket_private_t *)(ch->_privatePtr);
  +    
  +    if( strcmp( name, "name" )==0 ) {
  +        return  bean->name;
  +    } else if( strcmp( "host", name ) == 0 ) {
  +        return socketInfo->host;
  +    } else if( strcmp( "port", name ) == 0 ) {
  +        return jk2_env_itoa( env, socketInfo->port );
  +    } else if( strcmp( "nodelay", name ) == 0 ) {
  +        return jk2_env_itoa( env, socketInfo->ndelay );
  +    } else if( strcmp( "keepalive", name ) == 0 ) {
  +        return jk2_env_itoa( env, socketInfo->keepalive );
  +    } else if( strcmp( "timeout", name ) == 0 ) {
  +        return jk2_env_itoa( env, socketInfo->timeout );
  +    } else if( strcmp( "graceful", name ) == 0 ) {
  +        return jk2_env_itoa( env, ch->worker->graceful );
  +    } else if( strcmp( "debug", name ) == 0 ) {
  +        return jk2_env_itoa( env, ch->mbean->debug );
  +    } else if( strcmp( "disabled", name ) == 0 ) {
  +        return jk2_env_itoa( env, ch->mbean->disabled );
  +    }
  +    return NULL;
  +}
  +
  +
   /** resolve the host IP ( jk_resolve ) and initialize the channel.
    */
   static int JK_METHOD jk2_channel_apr_init(jk_env_t *env,
  @@ -185,6 +221,22 @@
       return rc;
   }
   
  +/*
  + * Wait input event on socket for timeout ms
  + */
  +static int JK_METHOD jk2_channel_apr_hasinput(jk_env_t *env,
  +                                              jk_channel_t *ch,
  +                                              jk_endpoint_t *endpoint,
  +											  int timeout)
  +
  +{
  +	/*
  +	 * Should implements the APR select/poll for socket here
  +	 */
  +	return (JK_TRUE) ;
  +}
  +
  +
   /** private: resolve the address on init
    */
   static int JK_METHOD jk2_channel_apr_resolve(jk_env_t *env,
  @@ -497,12 +549,20 @@
       ch->send= jk2_channel_apr_send; 
       ch->open= jk2_channel_apr_open; 
       ch->close= jk2_channel_apr_close; 
  +    ch->hasinput= jk2_channel_apr_hasinput; 
  +
       ch->is_stream=JK_TRUE;
   
       result->setAttribute= jk2_channel_apr_setProperty; 
  +    result->getAttribute= jk2_channel_apr_socket_getAttribute; 
  +    result->init= jk2_channel_apr_init; 
  +    result->getAttributeInfo=jk2_channel_apr_socket_getAttributeInfo;
  +    result->multiValueInfo=NULL;
  +    result->setAttributeInfo=jk2_channel_apr_socket_setAttributeInfo;
  +
       ch->mbean=result;
       result->object= ch;
  -    result->init= jk2_channel_apr_init; 
  +
   
       ch->workerEnv=env->getByName( env, "workerEnv" );
       ch->workerEnv->addChannel( env, ch->workerEnv, ch );
  
  
  
  1.57      +34 -1     jakarta-tomcat-connectors/jk/native2/common/jk_channel_socket.c
  
  Index: jk_channel_socket.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_channel_socket.c,v
  retrieving revision 1.56
  retrieving revision 1.57
  diff -u -r1.56 -r1.57
  --- jk_channel_socket.c	29 Aug 2003 13:08:57 -0000	1.56
  +++ jk_channel_socket.c	16 Oct 2003 07:51:48 -0000	1.57
  @@ -238,6 +238,39 @@
       return rc;
   }
   
  +/*
  + * Wait input event on socket for timeout ms
  + */
  +static int JK_METHOD jk2_channel_socket_hasinput(jk_env_t *env,
  +                                                 jk_channel_t *ch,
  +                                                 jk_endpoint_t *endpoint,
  +											     int timeout)
  +{
  +	fd_set  rset; 
  +	fd_set  eset; 
  +	struct  timeval tv;
  +	int		rc;
  +	
  +	FD_ZERO(&rset);
  +	FD_ZERO(&eset);
  +	FD_SET(endpoint->sd, &rset);
  +	FD_SET(endpoint->sd, &eset);
  +
  +	tv.tv_sec  = timeout / 1000;
  +	tv.tv_usec = (timeout % 1000) * 1000;
  +
  +	rc = select(ae->sd + 1, &rset, NULL, &eset, &tv);
  +      
  +    if ((rc < 1) || (FD_ISSET(endpoint->sd, &eset)))
  +	{
  +		env->l->jkLog(env, env->l, JK_LOG_ERROR, "jk2_channel_socket_isinput: "
  +						"error during select [%d]\n", rc);
  +		return JK_FALSE;
  +	}
  +	
  +	return ((FD_ISSET(endpoint->sd, &rset)) ? JK_TRUE : JK_FALSE) ;
  +}
  +
   /** private: resolve the address on init
    */
   static int JK_METHOD jk2_channel_socket_resolve(jk_env_t *env, char *host, short port,
  @@ -704,13 +737,13 @@
       ch->send= jk2_channel_socket_send; 
       ch->open= jk2_channel_socket_open; 
       ch->close= jk2_channel_socket_close; 
  +    ch->hasinput = jk2_channel_socket_hasinput; 
   
       ch->is_stream=JK_TRUE;
   
       result->setAttribute= jk2_channel_socket_setAttribute; 
       result->getAttribute= jk2_channel_socket_getAttribute; 
       result->init= jk2_channel_socket_init; 
  -
       result->getAttributeInfo=jk2_channel_socket_getAttributeInfo;
       result->multiValueInfo=NULL;
       result->setAttributeInfo=jk2_channel_socket_setAttributeInfo;
  
  
  
  1.29      +14 -0     jakarta-tomcat-connectors/jk/native2/common/jk_handler_response.c
  
  Index: jk_handler_response.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_handler_response.c,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- jk_handler_response.c	13 Mar 2003 18:30:46 -0000	1.28
  +++ jk_handler_response.c	16 Oct 2003 07:51:48 -0000	1.29
  @@ -255,6 +255,14 @@
       return JK_HANDLER_FATAL;	    
   }
   
  +/** PONG Reply handler
  + */
  +static int JK_METHOD jk2_handler_getPong(jk_env_t *env, void *target, 
  +                                         jk_endpoint_t *ae, jk_msg_t   *msg )
  +{
  +	return JK_HANDLER_LAST;
  +}
  +
   static int JK_METHOD jk2_handler_response_invoke(jk_env_t *env, jk_bean_t *bean, jk_endpoint_t *ep,
                                                    int code, jk_msg_t *msg, int raw)
   {
  @@ -269,6 +277,8 @@
           return jk2_handler_endResponse(env, target, ep, msg );
       case JK_HANDLE_AJP13_GET_BODY_CHUNK:
           return jk2_handler_getChunk(env, target, ep, msg );
  +    case JK_HANDLE_AJP13_PONG_REPLY:
  +        return jk2_handler_getPong(env, target, ep, msg );
       }
       return JK_OK;
   }
  @@ -292,6 +302,10 @@
       wEnv->registerHandler( env, wEnv, "handler.response",
                              "getChunk", JK_HANDLE_AJP13_GET_BODY_CHUNK,
                              jk2_handler_getChunk, NULL );
  +
  +    wEnv->registerHandler( env, wEnv, "handler.response",
  +                           "pongResponse", JK_HANDLE_AJP13_PONG_REPLY,
  +                           jk2_handler_getPong, NULL );
   
       return JK_OK;
   }
  
  
  
  1.42      +17 -0     jakarta-tomcat-connectors/jk/native2/common/jk_channel_jni.c
  
  Index: jk_channel_jni.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_channel_jni.c,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- jk_channel_jni.c	4 Feb 2003 07:39:59 -0000	1.41
  +++ jk_channel_jni.c	16 Oct 2003 07:51:48 -0000	1.42
  @@ -144,6 +144,22 @@
       return JK_OK;
   }
   
  +/*
  + * Wait input event for timeout ms
  + */
  +static int JK_METHOD jk2_channel_jni_hasinput(jk_env_t *env,
  +                                              jk_channel_t *ch,
  +                                              jk_endpoint_t *endpoint,
  +											  int timeout)
  +
  +{
  +	/*
  +	 * No delay in such case
  +	 */
  +	return (JK_TRUE) ;
  +}
  +
  +
   /** Assume the jni-worker or someone else started
    *  tomcat and initialized what is needed.
    */
  @@ -637,6 +653,7 @@
       ch->send= jk2_channel_jni_send; 
       ch->open= jk2_channel_jni_open; 
       ch->close= jk2_channel_jni_close; 
  +    ch->hasinput= jk2_channel_jni_hasinput; 
   
       ch->beforeRequest= jk2_channel_jni_beforeRequest;
       ch->afterRequest= jk2_channel_jni_afterRequest;
  
  
  
  1.9       +9 -0      jakarta-tomcat-connectors/jk/native2/common/jk_channel.c
  
  Index: jk_channel.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_channel.c,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- jk_channel.c	4 Feb 2003 07:39:59 -0000	1.8
  +++ jk_channel.c	16 Oct 2003 07:51:48 -0000	1.9
  @@ -140,6 +140,15 @@
               rc=ch->send(env, ch, ep, msg);
           return rc;
       }
  +    case CH_HASINPUT: {
  +        if( ch->mbean->debug > 0 )
  +            env->l->jkLog(env, env->l, JK_LOG_DEBUG, "ch.hasinput()\n");
  +        if( ch->serverSide )
  +            msg->serverSide=JK_TRUE;
  +        if( ch->hasinput != NULL )
  +            rc=ch->hasinput(env, ch, ep, 1000);	/* Well we should handle timeout better isn't it ? */
  +        return rc;
  +    }
       }/* switch */
       return JK_ERR;
   }
  
  
  
  1.50      +109 -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.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- jk_worker_ajp13.c	25 Sep 2003 15:23:22 -0000	1.49
  +++ jk_worker_ajp13.c	16 Oct 2003 07:51:48 -0000	1.50
  @@ -84,12 +84,14 @@
   /* -------------------- Impl -------------------- */
   static char *jk2_worker_ajp13_getAttributeInfo[]={ "lb_factor", "lb_value", "debug", "channel", "level",
                                                      "route", "routeRedirect", "errorState", "graceful", "groups", "disabled", 
  -                                                   "epCount", "errorTime", NULL };
  +                                                   "epCount", "errorTime", "connectTimeout", "replyTimeout",
  +                                                   "prepostTimeout", NULL };
   
   static char *jk2_worker_ajp13_multiValueInfo[]={"group", NULL };
   
   static char *jk2_worker_ajp13_setAttributeInfo[]={"debug", "channel", "route", "routeRedirect","secretkey", "group", "graceful",
  -                                                  "disabled", "lb_factor", "level", NULL };
  +                                                  "disabled", "lb_factor", "level", "connectTimeout", "replyTimeout",
  +                                                   "prepostTimeout", NULL };
   
   
   static void * JK_METHOD jk2_worker_ajp13_getAttribute(jk_env_t *env, jk_bean_t *bean, char *name ) {
  @@ -121,6 +123,12 @@
           return jk2_env_itoa( env, worker->in_error_state );
       } else if (strcmp( name, "graceful" )==0 ) {
           return jk2_env_itoa( env, worker->graceful );
  +    } else if (strcmp( name, "connectTimeout" )==0 ) {
  +        return jk2_env_itoa( env, worket->connect_timeout);
  +    } else if (strcmp( name, "replyTimeout" )==0 ) {
  +        return jk2_env_itoa( env, worker->reply_timeout);
  +    } else if (strcmp( name, "prepostTimeout" )==0 ) {
  +        return jk2_env_itoa( env, worker->prepost_timeout);
       } else if (strcmp( name, "disabled" )==0 ) {
           return jk2_env_itoa( env, bean->disabled );
       } else if (strcmp( name, "epCount" )==0 ) {
  @@ -152,6 +160,12 @@
           ajp13->routeRedirect=value;
       } else if( strcmp( name, "graceful" )==0 ) {
           ajp13->graceful=atoi( value );
  +    } else if( strcmp( name, "connectTimeout" )==0 ) {
  +        ajp13->connect_timeout=atoi( value );
  +    } else if( strcmp( name, "replyTimeout" )==0 ) {
  +        ajp13->reply_timeout=atoi( value );
  +    } else if( strcmp( name, "prepostTimeout" )==0 ) {
  +        ajp13->prepost_timeout=atoi( value );
       } else if( strcmp( name, "disabled" )==0 ) {
           mbean->disabled=atoi( value );
       } else if( strcmp( name, "group" )==0 ) {
  @@ -171,14 +185,21 @@
       return JK_OK;
   }
   
  +/* Webserver ask container to take control (logon phase) */
   #define JK_AJP13_PING               (unsigned char)8
   
  +/* Webserver check if container is alive, since container should respond by cpong */
  +#define JK_AJP13_CPING              (unsigned char)10
  +
  +/* Container response to cping request */
  +#define JK_AJP13_CPONG				(unsigned char)9
  +
   /* 
    * Build the ping cmd. Tomcat will get control and will be able 
    * to send any command.
    *
    * +-----------------------+
  - * | PING CMD (1 byte) |
  + * | PING CMD (1 byte)     |
    * +-----------------------+
    *
    * XXX Add optional Key/Value set .
  @@ -200,6 +221,32 @@
   }
   
   
  +/* 
  + * Build the cping cmd. Tomcat should respond by a cpong.
  + *
  + * +-----------------------+
  + * | CPING CMD (1 byte)    |
  + * +-----------------------+
  + *
  + * XXX Add optional Key/Value set .
  + *  
  + */
  +int jk2_serialize_cping(jk_env_t *env, jk_msg_t *msg,
  +                       jk_endpoint_t *ae)
  +{
  +    int rc;
  +    
  +    /* To be on the safe side */
  +    msg->reset(env, msg);
  +
  +    rc= msg->appendByte( env, msg, JK_AJP13_CPING);
  +    if (rc!=JK_OK )
  +        return JK_ERR;
  +
  +    return JK_OK;
  +}
  +
  +
   /*
    * Close the endpoint (clean buf and close socket)
    */
  @@ -225,6 +272,50 @@
       /*     ae->pool->close( env, ae->pool ); */
   }
   
  +/** Check if a channel is alive, send a cping and wait for a cpong
  +    during timeoutms
  + */
  +static int jk2_check_alive(jk_env_t *env, jk_endpoint_t *ae, int timeout) {
  +
  +    jk_channel_t *channel=ae->worker->channel;
  +    jk_msg_t * msg=ae->reply;
  +;
  +
  +	jk2_serialize_cping( env, msg, ae );
  +	err = ae->worker->channel->send( env, ae->worker->channel, ae, msg );
  +
  +	if (err != JK_OK) {
  +        env->l->jkLog(env, env->l, JK_LOG_ERROR,
  +                      "ajp13.checkalive() can't send cping request to %s\n", 
  +                      ae->worker->mbean->name);
  +
  +		return JK_ERR;
  +	}
  +	
  +	if (ae->worker->channel->hasinput(env, ae->worker->channel, ae, 
  +	                                  timeout) != JK_TRUE) {
  +	                                  
  +        env->l->jkLog(env, env->l, JK_LOG_ERROR,
  +                      "ajp13.checkalive() can't get cpong reply from %s in %d ms\n", 
  +                      ae->worker->mbean->name, timeout);
  +
  +		return JK_ERR;
  +	}
  +	
  +	err = ae->worker->channel->recv( env, ae->worker->channel, ae, msg );
  +
  +	if (err != JK_OK) {
  +        env->l->jkLog(env, env->l, JK_LOG_ERROR,
  +                      "ajp13.checkalive() can't read cpong reply from %s\n", 
  +                      ae->worker->mbean->name);
  +
  +		return JK_ERR;
  +	}
  +	
  +	
  +	return JK_OK;
  +}
  +
   /** Connect a channel, implementing the logging protocol if ajp13
    */
   static int jk2_worker_ajp13_connect(jk_env_t *env, jk_endpoint_t *ae) {
  @@ -262,6 +353,11 @@
       /** XXX use a 'connected' field */
       if( ae->sd == -1 ) ae->sd=0;
       
  +	if (ae->worker->connect_timeout != 0 )
  +		if (jk2_check_alive(env, ae, ae->worker->connect_timeout) != JK_OK)
  +    		return JK_ERR;
  +	}
  +
       /* Check if we must execute a logon after the physical connect */
       if (ae->worker->secret == NULL)
           return JK_OK;
  @@ -269,15 +365,15 @@
       /* Do the logon process */
       env->l->jkLog(env, env->l, JK_LOG_INFO, "ajp13.connect() logging in\n" );
   
  -    /* use the reply buffer - it's a new channel, it is cetainly not
  +    /* use the reply buffer - it's a new channel, it is certainly not
        in use. The request and post buffers are probably in use if this
       is a reconnect */
       msg=ae->reply;
   
  -    jk2_serialize_ping( env, msg, ae );
  -    
  -    err = ae->worker->channel->send( env, ae->worker->channel, ae, msg );
  -
  +	/* send a ping message to told container to take control (logon phase) */
  +	jk2_serialize_ping( env, msg, ae );
  +	err = ae->worker->channel->send( env, ae->worker->channel, ae, msg );
  +	
       /* Move to 'slave' mode, listening to messages */
       err=ae->worker->workerEnv->processCallbacks( env, ae->worker->workerEnv,
                                                    ae, NULL);
  @@ -485,6 +581,11 @@
       s->left_bytes_to_send = s->content_length;
       s->content_read=0;
   
  +	if (w->prepost_timeout != 0) {
  +		if (jk2_check_alive(env, ae, ae->worker->prepost_timeout) != JK_OK)
  +    		return JK_ERR;
  +	}
  +	
       /* 
        * We get here initial request (in reqmsg)
        */
  
  
  
  1.19      +6 -0      jakarta-tomcat-connectors/jk/native2/include/jk_channel.h
  
  Index: jk_channel.h
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/include/jk_channel.h,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- jk_channel.h	4 Feb 2003 07:40:32 -0000	1.18
  +++ jk_channel.h	16 Oct 2003 07:51:48 -0000	1.19
  @@ -78,6 +78,7 @@
   #define CH_CLOSE 5
   #define CH_READ 6
   #define CH_WRITE 7
  +#define CH_HASINPUT 8
       
   typedef struct jk_channel jk_channel_t;
   
  @@ -146,6 +147,11 @@
       int (JK_METHOD *recv)(struct jk_env *env, jk_channel_t *_this,
   			  struct jk_endpoint *endpoint,
                             struct jk_msg *msg );
  +
  +    /** Check if something is available in input on the communication channel
  +     */
  +    int (JK_METHOD *hasinput)(struct jk_env *env, jk_channel_t *_this,
  +			  struct jk_endpoint *endpoint, int timeout);
   
       /** Called before request processing, to initialize resources.
           All following calls will be in the same thread.
  
  
  
  1.29      +4 -1      jakarta-tomcat-connectors/jk/native2/include/jk_workerEnv.h
  
  Index: jk_workerEnv.h
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/include/jk_workerEnv.h,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- jk_workerEnv.h	4 Feb 2003 07:40:32 -0000	1.28
  +++ jk_workerEnv.h	16 Oct 2003 07:51:48 -0000	1.29
  @@ -106,6 +106,9 @@
   /*  Marks the end of response. */
   #define JK_HANDLE_AJP13_END_RESPONSE       5
   
  +/* Get a PONG reply from the servlet container. */
  +#define JK_HANDLE_AJP13_PONG_REPLY       9
  +
   /* Second Login Phase (servlet engine -> web server), md5 seed is received */
   #define JK_HANDLE_LOGON_SEED	0x11
   
  
  
  
  1.32      +17 -1     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.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- jk_worker.h	8 Apr 2003 04:00:24 -0000	1.31
  +++ jk_worker.h	16 Oct 2003 07:51:48 -0000	1.32
  @@ -217,6 +217,22 @@
           session IDs matching the worker will be forwarded, nothing else */
       int graceful;
       
  +    /** Delay in ms at connect time for Tomcat to respond to a PING request 
  +     *  at connect time (ensure that Tomcat is not HOLDED)
  +     */
  +    int connect_timeout;
  +    
  +    /** When set, indicate delay in ms to wait a reply.
  +     *  Warning it will mark as invalid long running request, should be set with
  +     *  care but could be usefull to detect an HOLDED Tomcat.
  +     */
  +    int reply_timeout;
  +    
  +    /** Delay in ms for Tomcat to respond to a PING request before 
  +     *  webserver start sending the request (ensure that Tomcat is not HOLDED)
  +     */
  +    int prepost_timeout;
  +    
       /* Worker priority.
        * Workers with lower priority are allways preffered - regardless of lb_value
        * This is user to represent 'local' workers ( we can call it 'proximity' or 'distance' )
  
  
  

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


Re: cvs commit: jakarta-tomcat-connectors/jk/native2/include jk_channel.h jk_workerEnv.h jk_worker.h

Posted by Henri Gomez <hg...@apache.org>.
Mladen Turk a écrit :

> 
>>-----Original Message-----
>>From: hgomez@apache.org
>>  
>>  1.17      +17 -0     
>>jakarta-tomcat-connectors/jk/native2/common/jk_channel_un.c
>>  
>>  
>>  1.6       +3 -3      
>>jakarta-tomcat-connectors/jk/native2/common/jk_mutex.c
>>  
>>  
>>  1.57      +34 -1     
>>jakarta-tomcat-connectors/jk/native2/common/jk_channel_socket.c
> 
> 
> Henri,
> 
> IMO all of those should be deprecated.
> 
> Instead of jk_mutex use the apr_anylock, or apr_thread_mutex cause it's
> meant for thread locking, not as interposes mutex.
> and remove the channel_un and channel_socket.

Ok for jk_mutex and channel_socket but we should keep channel_un which
is requested by many people.

In fact it's one of the features of jk2 would convince some admins to
use jk2 in favor of jk ;)


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


RE: cvs commit: jakarta-tomcat-connectors/jk/native2/include jk_channel.h jk_workerEnv.h jk_worker.h

Posted by Mladen Turk <mt...@apache.org>.

> -----Original Message-----
> From: hgomez@apache.org
>   
>   1.17      +17 -0     
> jakarta-tomcat-connectors/jk/native2/common/jk_channel_un.c
>   
>   
>   1.6       +3 -3      
> jakarta-tomcat-connectors/jk/native2/common/jk_mutex.c
>   
>   
>   1.57      +34 -1     
> jakarta-tomcat-connectors/jk/native2/common/jk_channel_socket.c

Henri,

IMO all of those should be deprecated.

Instead of jk_mutex use the apr_anylock, or apr_thread_mutex cause it's
meant for thread locking, not as interposes mutex.
and remove the channel_un and channel_socket.

MT.




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