mturk 2002/11/21 01:03:18 Modified: jk/native2/common jk_worker_lb.c jk_channel_jni.c jk_channel.c Log: Get rid of the one-shot worker initialization scheme. It doesn't work as it should, and it slows down the load balacer. Once when service channel will be introduced it will take care of that. Revision Changes Path 1.28 +9 -62 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.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- jk_worker_lb.c 21 Nov 2002 07:46:41 -0000 1.27 +++ jk_worker_lb.c 21 Nov 2002 09:03:17 -0000 1.28 @@ -85,7 +85,6 @@ typedef struct { struct jk_mutex *cs; - int initializing; int attempts; int recovery; int timeout; @@ -334,35 +333,12 @@ /* Since there is potential worker state change * make the find best worker call thread safe */ - if (!lb_priv->initializing) { - if (lb_priv->cs != NULL) - lb_priv->cs->lock(env, lb_priv->cs); - rec=jk2_get_most_suitable_worker(env, lb, s, attempt); - - if (lb_priv->cs != NULL) - lb_priv->cs->unLock(env, lb_priv->cs); - if (!rec && lb_priv->timeout) { - time_t now = time(NULL); - if ((int)(now - lb_priv->error_time) < lb_priv->timeout) { -#ifdef HAS_APR - apr_thread_yield(); -#endif - continue; - } - } - else - lb_priv->error_time = time(NULL); - } - else if (!rec){ - /* If we are initializing the service wait until - * the initialization finishes or times out - */ - if (lb->cs != NULL) { - lb->cs->lock(env, lb->cs); - lb->cs->unLock(env, lb->cs); - } - continue; - } + if (lb_priv->cs != NULL) + lb_priv->cs->lock(env, lb_priv->cs); + rec=jk2_get_most_suitable_worker(env, lb, s, attempt); + + if (lb_priv->cs != NULL) + lb_priv->cs->unLock(env, lb_priv->cs); attempt++; s->is_recoverable_error = JK_FALSE; @@ -405,50 +381,21 @@ s->jvm_route = rec->route; s->realWorker = rec; - if (rec->mbean->initialize && !lb_priv->initializing && lb->cs != NULL) { - /* If the worker has not been called yet serialize the call */ - lb->cs->lock(env, lb->cs); - lb_priv->initializing = JK_TRUE; - rec->error_time = time(NULL); - } + rc = rec->service(env, rec, s); if(rc==JK_OK) { rec->in_error_state = JK_FALSE; rec->error_time = 0; - /* Set the initialized flag to TRUE if that was the first call */ - if (rec->mbean->initialize && lb->cs != NULL) { - rec->mbean->initialize = 0; - lb_priv->initializing = JK_FALSE; - lb->cs->unLock(env, lb->cs); - } return JK_OK; } - if (rec->mbean->initialize && lb->cs != NULL) { - time_t now = time(NULL); - /* In the case of initialization timeout disable the worker */ - if ((int)(now - rec->error_time) > rec->mbean->initialize) { - rec->mbean->disabled = JK_TRUE; - lb_priv->initializing = JK_FALSE; - s->is_recoverable_error = JK_FALSE; - env->l->jkLog(env, env->l, JK_LOG_ERROR, - "lb_worker.service() worker init timeout for %s\n", - rec->channelName); - lb->cs->unLock(env, lb->cs); - } - else { -#ifdef HAS_APR - apr_thread_yield(); -#endif - continue; - } - } /* If this is a browser connection error dont't check other * workers. */ if (rc == JK_HANDLER_ERROR) { - + rec->in_error_state = JK_FALSE; + rec->error_time = 0; return JK_HANDLER_ERROR; } 1.38 +1 -3 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.37 retrieving revision 1.38 diff -u -r1.37 -r1.38 --- jk_channel_jni.c 6 Nov 2002 16:32:25 -0000 1.37 +++ jk_channel_jni.c 21 Nov 2002 09:03:17 -0000 1.38 @@ -139,7 +139,6 @@ "channel_jni.init() no VM found\n" ); if( jniW->worker != NULL ) { jniW->worker->mbean->disabled=JK_TRUE; - jniW->worker->mbean->initialize=60; } return JK_ERR; } @@ -614,7 +613,7 @@ { jk_channel_jni_private_t *jniCh=_this->_privatePtr; - if ( jniCh->status != JNI_TOMCAT_STARTED && worker->mbean->initialize) { + if ( jniCh->status != JNI_TOMCAT_STARTED) { jniCh->status = jk_jni_status_code; if (jniCh->status != JNI_TOMCAT_STARTED) return JK_ERR; @@ -660,7 +659,6 @@ wEnv->addChannel( env, wEnv, ch ); result->invoke=jk2_channel_jni_invoke; - ch->worker->mbean->initialize = 60; return JK_OK; } 1.7 +0 -4 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.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- jk_channel.c 8 Jul 2002 13:42:14 -0000 1.6 +++ jk_channel.c 21 Nov 2002 09:03:17 -0000 1.7 @@ -84,10 +84,6 @@ ch->mbean->disabled=atoi( value ); if( ch->worker!=NULL) ch->worker->mbean->disabled=ch->mbean->disabled; - } else if( strcmp( "init", name ) == 0 ) { - ch->worker->mbean->initialize=atoi( value ); - if( ch->worker!=NULL) - ch->worker->mbean->disabled=ch->mbean->disabled; } else { if( ch->worker!=NULL ) { return ch->worker->mbean->setAttribute( env, ch->worker->mbean, name, valueP );
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>