costin 02/01/11 20:03:42 Modified: jk/java/org/apache/jk/common ChannelUn.java MsgAjp.java Added: jk/java/org/apache/jk/common ChannelJni.java Log: Added the template for the jni channel. Work is underway on the C side as well. Few fixes/enhancements for the Unix channel ( to locate the native libs with less user intervention ) Revision Changes Path 1.2 +14 -8 jakarta-tomcat-connectors/jk/java/org/apache/jk/common/ChannelUn.java Index: ChannelUn.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/jk/common/ChannelUn.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ChannelUn.java 6 Jan 2002 08:42:09 -0000 1.1 +++ ChannelUn.java 12 Jan 2002 04:03:42 -0000 1.2 @@ -82,6 +82,7 @@ String file; Worker worker; ThreadPool tp=new ThreadPool(); + String jkHome; /* ==================== Tcp socket options ==================== */ @@ -101,6 +102,13 @@ file=f; } + /** Set the base dir of the jk webapp. This is used to locate + * the (fixed) path to the native lib. + */ + public void setJkHome( String s ) { + jkHome=s; + } + /* ==================== ==================== */ long unixListenSocket; int socketNote=1; @@ -121,10 +129,10 @@ public void init() throws IOException { apr=new AprImpl(); - File f=new File( "../jk2/jni/libapr.so" ); - apr.loadNative( f.getAbsolutePath() ); - f=new File( "../jk2/jni/jni_connect.so" ); - apr.loadNative( f.getAbsolutePath() ); + File f=new File( jkHome ); + File aprBase=new File( jkHome, "/WEB-INF/jk2/jni" ); + apr.setBaseDir( aprBase.getAbsolutePath() ); + apr.loadNative(); apr.initialize(); gPool=apr.poolCreate( 0 ); @@ -191,15 +199,13 @@ int pos = 0; int got; - if (dL > 5) { - d("reading # " + b + " " + (b==null ? 0: b.length) + " " + offset + " " + len); - } while(pos < len) { got=apr.unRead( gPool, s.longValue(), b, pos + offset, len - pos); if (dL > 5) { - d("read got # " + got); + d("reading # " + b + " " + (b==null ? 0: b.length) + " " + + offset + " " + len + " got # " + got); } // connection just closed by remote. if (got <= 0) { 1.3 +2 -3 jakarta-tomcat-connectors/jk/java/org/apache/jk/common/MsgAjp.java Index: MsgAjp.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/jk/common/MsgAjp.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- MsgAjp.java 6 Jan 2002 08:46:10 -0000 1.2 +++ MsgAjp.java 12 Jan 2002 04:03:42 -0000 1.3 @@ -173,7 +173,8 @@ } public void appendByteChunk(ByteChunk bc) throws IOException { - if(bc==null || bc.isNull() ) { + if(bc==null ) { + System.out.println("XXX appending BC null" + bc); appendInt( 0); appendByte(0); return; @@ -182,8 +183,6 @@ byte[] bytes = bc.getBytes(); int start=bc.getStart(); appendInt( bc.getLength() ); - System.out.println("XXX appending" + bytes + " " + bc.getLength() + - " " + new String( bytes, 0, bc.getLength())); cpBytes(bytes, start, bc.getLength()); appendByte(0); } 1.1 jakarta-tomcat-connectors/jk/java/org/apache/jk/common/ChannelJni.java Index: ChannelJni.java =================================================================== /* * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 1999 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * * [Additional notices, if required by prior licensing conditions] * */ package org.apache.jk.common; import java.io.*; import java.net.*; import java.util.*; import org.apache.tomcat.util.buf.*; import org.apache.tomcat.util.http.*; import org.apache.tomcat.util.threads.*; import org.apache.jk.core.*; import org.apache.jk.apr.*; /** Pass messages using unix domain sockets. * * @author Costin Manolache */ public class ChannelJni extends Channel { /* ==================== ==================== */ static WorkerEnv wenv=null; public static int startup(String cmdLine, String stdout, String stderr) { System.out.println("In startup"); System.err.println("In startup err"); if( wenv!=null ) { d("Second call, ignored "); return 1; } try { if(null != stdout) { PrintStream out=new PrintStream(new FileOutputStream(stdout)); System.setOut(out); if( stderr==null ) System.setErr(out); } if(null != stderr) { PrintStream err=new PrintStream(new FileOutputStream(stderr)); System.setErr(err); if( stdout==null ) System.setOut(err); } if( stdout==null && stderr==null ) { // no problem, use stderr - it'll go to error.log of the server. System.setOut( System.err ); } } catch(Throwable t) { } System.out.println("New stream"); System.err.println("New err stream"); return 1; } public static int service(long s, long l) { System.out.println("In service"); return 0; } public static void shutdown() { System.out.println("In shutdown"); } private static final int dL=0; private static void d(String s ) { System.err.println( "ChannelJni: " + s ); } }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>