costin 02/03/24 19:34:38 Modified: jk/native2/common jk_worker_ajp13.c Log: Magic to set the channel. The worker.init() will create a channel automatically if none is specified. ( it'll be better to configure the channel and create the worker automatically ) Revision Changes Path 1.4 +50 -4 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.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- jk_worker_ajp13.c 24 Mar 2002 19:24:26 -0000 1.3 +++ jk_worker_ajp13.c 25 Mar 2002 03:34:38 -0000 1.4 @@ -381,6 +381,12 @@ return JK_FALSE; } + if( w->channel==NULL ) { + env->l->jkLog(env, env->l, JK_LOG_INFO, + "ajp14.service() no channel defined, error in init\n", w->mbean->name); + return JK_FALSE; + } + e->currentRequest=s; /* Prepare the messages we'll use.*/ @@ -409,7 +415,7 @@ } env->l->jkLog(env, env->l, JK_LOG_INFO, - "ajp14.service() %s\n", w->channel->mbean->name); + "ajp14.service() %s\n", w->channelName); if( w->channel->beforeRequest != NULL ) { w->channel->beforeRequest( env, w->channel, w, e, s ); @@ -542,15 +548,55 @@ } if( ajp14->channelName == NULL ) { - ajp14->channelName="channel.default"; + /* No "channel" was specified. Default to a channel, using + the local part of the worker name to construct it. The type + of the channel will be unix socket if a / is found, jni if + the name is jni, and socket otherwise. + + If the channle is not found, create one. + */ + char *localName=strchr( ajp14->mbean->name, ':' ); + if( localName==NULL || localName[1]=='\0' ) { + /* No local part, use the defaults */ + ajp14->channelName="channel.socket"; + } else { + char *prefix; + localName++; + if( strcmp( localName, "jni" ) == 0 ) { + /* Easy one */ + ajp14->channelName="channel.jni"; + } else { + if( strchr( localName, '/' )) { + prefix="channel.apr:"; + } else { + /* We could do more - if other channels are defined and + we can guess it */ + prefix="channel.socket:"; + } + ajp14->channelName=ajp14->pool->calloc( env, ajp14->pool, strlen( localName )+ + strlen( prefix ) + 2 ); + strcpy( ajp14->channelName, prefix ); + strcat( ajp14->channelName, localName ); + } + } } ajp14->channel= env->getByName( env, ajp14->channelName ); if( ajp14->channel == NULL ) { - /* XXX Create a default channel using socket/localhost/8009 ! */ + jk_bean_t * chB=env->createBean( env, ajp14->workerEnv->pool, ajp14->channelName); + if( chB==NULL ) { + env->l->jkLog(env, env->l, JK_LOG_ERROR, + "ajp14.init(): can't create channel %s\n", + ajp14->channelName); + return JK_FALSE; + } + ajp14->channel = chB->object; + } + + if( ajp14->channel == NULL ) { env->l->jkLog(env, env->l, JK_LOG_ERROR, - "ajp14.validate(): no channel found %s\n", + "ajp14.init(): no channel found %s\n", ajp14->channelName); return JK_FALSE; }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>