Skip to content

Instantly share code, notes, and snippets.

@huksley
Last active December 18, 2015 03:48
Show Gist options
  • Save huksley/5720450 to your computer and use it in GitHub Desktop.
Save huksley/5720450 to your computer and use it in GitHub Desktop.
Full build Tomcat Native library on Debian based system, with Java 6 compatibility.
diff -rwu tomcat-native-1.1.27-src/jni/java/org/apache/tomcat/jni/socket/AprSocketContext.java tomcat-native-1.1.27-src-java6/jni/java/org/apache/tomcat/jni/socket/AprSocketContext.java
--- tomcat-native-1.1.27-src/jni/java/org/apache/tomcat/jni/socket/AprSocketContext.java 2012-10-27 01:33:31.000000000 +0400
+++ tomcat-native-1.1.27-src-java6/jni/java/org/apache/tomcat/jni/socket/AprSocketContext.java 2013-06-06 13:04:22.535458514 +0400
@@ -118,7 +118,7 @@
/**
* Pollers.
*/
- List<AprPoller> pollers = new ArrayList<>();
+ List<AprPoller> pollers = new ArrayList<AprPoller>();
static int pollerCnt = 0;
// Set on all accepted or connected sockets.
@@ -133,7 +133,7 @@
// If false: use executor ( but that may choke the acceptor thread )
protected boolean nonBlockingAccept = false;
- BlockingQueue<AprSocket> acceptedQueue = new LinkedBlockingQueue<>();
+ BlockingQueue<AprSocket> acceptedQueue = new LinkedBlockingQueue<AprSocket>();
/**
* Root APR memory pool.
@@ -167,7 +167,7 @@
RawDataHandler rawDataHandler = null;
// TODO: do we need this here ?
- protected Map<String, HostInfo> hosts = new HashMap<>();
+ protected Map<String, HostInfo> hosts = new HashMap<String, HostInfo>();
String[] enabledCiphers;
@@ -810,12 +810,19 @@
}
void unblock() {
- try (java.net.Socket sock = new java.net.Socket()) {
+ java.net.Socket sock = new java.net.Socket();
+ try {
// Easiest ( maybe safest ) way to interrupt accept
// we could have it in non-blocking mode, etc
sock.connect(new InetSocketAddress("127.0.0.1", port));
} catch (Exception ex) {
// ignore - the acceptor may have shut down by itself.
+ } finally {
+ try {
+ sock.close();
+ } catch (IOException ee) {
+ // ignore
+ }
}
}
@@ -956,7 +963,7 @@
// Should be replaced with socket data.
// used only to lookup by socket
- Map<Long, AprSocket> channels = new HashMap<>();
+ Map<Long, AprSocket> channels = new HashMap<Long, AprSocket>();
// Active + pending, must be < desc.length / 2
// The channel will also have poller=this when active or pending
@@ -967,7 +974,7 @@
protected AtomicInteger pollCount = new AtomicInteger();
- private List<AprSocket> updates = new ArrayList<>();
+ private List<AprSocket> updates = new ArrayList<AprSocket>();
@Override
public void run() {
#!/bin/sh
set -e
# Install stuff, be sure to install JDK yourselves
sudo -E apt-get install libapr1-dev gcc make ant patch -y
ver=1.1.27
hh=$PWD
# Must apply patch to build for Java6
# diff -rwu tomcat-native-1.1.27-src/jni/java tomcat-native-1.1.27-src-java6/jni/java > tomcat-native-1.1.27-java6.patch
rm -rf tomcat-native-$ver-src.tar.gz tomcat-native-$ver-src.tar tomcat-native-$ver-src
wget -O tomcat-native-$ver-src.tar.gz http://www.apache.org/dist/tomcat/tomcat-connectors/native/$ver/source/tomcat-native-$ver-src.tar.gz
gzip -f -q -d tomcat-native-$ver-src.tar.gz
tar -xf tomcat-native-$ver-src.tar
cd tomcat-native-$ver-src/jni
patch -p2 < ../../tomcat-native-$ver-java6.patch
ant -f build.xml -Dcompile.source=1.6 -Dcompile.target=1.6 jar
cd native
if [ "$JAVA_HOME"="" ]; then
JAVA_HOME=`find /etc/alternatives/javac -printf %l | sed -re "s/\/bin\/javac//g"`
fi
echo $JAVA_HOME
./configure --with-apr=/usr --with-java-home=$JAVA_HOME
make
cp -L .libs/libtcnative-1.so $hh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment