You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by co...@apache.org on 2002/05/29 00:50:37 UTC
cvs commit: jakarta-tomcat-connectors/jk/java/org/apache/jk/common JniHandler.java
costin 02/05/28 15:50:37
Modified: jk/java/org/apache/jk/common JniHandler.java
Log:
Few fixes and enhancements, making sure everything works.
Revision Changes Path
1.6 +71 -9 jakarta-tomcat-connectors/jk/java/org/apache/jk/common/JniHandler.java
Index: JniHandler.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/jk/common/JniHandler.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- JniHandler.java 26 May 2002 07:13:59 -0000 1.5
+++ JniHandler.java 28 May 2002 22:50:37 -0000 1.6
@@ -151,6 +151,9 @@
try {
MsgContext msgCtx=new MsgContext();
MsgAjp msg=new MsgAjp();
+
+ msgCtx.setSource( this );
+ msgCtx.setWorkerEnv( wEnv );
msgCtx.setNext( this );
@@ -168,11 +171,60 @@
}
}
+ public void setNativeAttribute(String name, String val) throws IOException {
+ if( apr==null ) return;
+
+ if( nativeJkHandlerP == 0 ) {
+ log.error( "Unitialized component " + name+ " " + val );
+ return;
+ }
+
+ long xEnv=apr.getJkEnv();
+
+ apr.jkSetAttribute( xEnv, nativeJkHandlerP, name, val );
+
+ apr.releaseJkEnv( xEnv );
+ }
+
+ public void initJkComponent() throws IOException {
+ if( apr==null ) return;
+
+ if( nativeJkHandlerP == 0 ) {
+ log.error( "Unitialized component " );
+ return;
+ }
+
+ long xEnv=apr.getJkEnv();
+
+ apr.jkInit( xEnv, nativeJkHandlerP );
+
+ apr.releaseJkEnv( xEnv );
+ }
+
+ public void destroyJkComponent() throws IOException {
+ if( apr==null ) return;
+
+ if( nativeJkHandlerP == 0 ) {
+ log.error( "Unitialized component " );
+ return;
+ }
+
+ long xEnv=apr.getJkEnv();
+
+ apr.jkDestroy( xEnv, nativeJkHandlerP );
+
+ apr.releaseJkEnv( xEnv );
+ }
+
+
+
protected void setNativeEndpoint(MsgContext msgCtx) {
long xEnv=apr.getJkEnv();
msgCtx.setJniEnv( xEnv );
long epP=apr.createJkHandler(xEnv, "endpoint");
+ log.debug("create ep " + epP );
+ if( epP == 0 ) return;
apr.jkInit( xEnv, epP );
msgCtx.setJniContext( epP );
@@ -184,12 +236,19 @@
/** send and get the response in the same buffer.
*/
- protected int nativeDispatch( Msg msg, MsgContext ep, int code )
+ protected int nativeDispatch( Msg msg, MsgContext ep, int code, int raw )
throws IOException
{
- if( log.isDebugEnabled() ) log.debug( "Sending packet ");
- msg.end();
- if( log.isTraceEnabled() ) msg.dump("OUT:" );
+ if( log.isDebugEnabled() ) log.debug( "Sending packet " + code + " " + raw);
+
+ if( raw == 0 ) {
+ msg.end();
+
+ if( log.isTraceEnabled() ) msg.dump("OUT:" );
+ }
+
+ // Create ( or reuse ) the jk_endpoint ( the native pair of
+ // MsgContext )
long xEnv=ep.getJniEnv();
long nativeContext=ep.getJniContext();
if( nativeContext==0 || xEnv==0 ) {
@@ -204,11 +263,13 @@
}
// Will process the message in the current thread.
- // No wait needed to receive the response
+ // No wait needed to receive the response, if any
int status=apr.jkInvoke( xEnv,
nativeJkHandlerP,
nativeContext,
- code, msg.getBuffer(), msg.getLen());
+ code, msg.getBuffer(), 0, msg.getLen(), raw );
+ if( status != 0 )
+ log.error( "nativeDispatch: error " + status );
if( log.isDebugEnabled() ) log.debug( "Sending packet - done " + status);
return status;
@@ -227,13 +288,14 @@
// return send( msg, ep );
}
- int status=nativeDispatch(msg, ep, type );
+ int status=nativeDispatch(msg, ep, type, 0 );
apr.jkRecycle(xEnv, ep.getJniContext());
if(log.isInfoEnabled() ) log.info("Shm invoke status " + status);
-
- return 0;
+
+ apr.releaseJkEnv( xEnv );
+ return 0;
}
private static org.apache.commons.logging.Log log=
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>