Skip to content

Commit 490e166

Browse files
committed
fix linux
1 parent 1ae381e commit 490e166

15 files changed

+76
-3671
lines changed

README.md

+9-3
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ self-contained application file less than 4Mb in size.
2121

2222
## Drawbacks
2323

24-
There is a `src/util` directory containing parts of a standard jdk source files + primitive thread pool implementation.
25-
The reason for this is that Avian does not implement many parts of a Java standard library.
24+
There is a `src/util` directory containing the primitive thread pool and blocking queue implementations, that
25+
should be easily found within the java standard library. The reason for this is that Avian does not implement
26+
many parts of jdk and we have to "reinvent a wheel" for some features.
2627

2728
## Advanced settings
2829

@@ -38,4 +39,9 @@ in the respective properties within `gradle.properties` file:
3839
```properties
3940
OPEN_JDK_PATH=/absolute/path/to/openjdk/distribution
4041
OPEN_JDK_SRC_PATH=/absolute/path/to/openjdk/source/code
41-
```
42+
```
43+
44+
## Drawbacks
45+
46+
* The proven compatible version of OpenJDK is openjdk-7u111 (as of November 2016). Not sure if others will work as well.
47+
* The resulting size of a self-contained file will be tens of megabytes instead of a few.

avian.gradle

+4-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ static platform() {
99
}
1010

1111
static arch() {
12-
System.getProperty("os.arch")
12+
final s = System.getProperty("os.arch")
13+
s == "amd64" ? "x86_64" : s
1314
}
1415

1516
static java_home() {
@@ -26,7 +27,7 @@ def avianBuildDir(File buildDir) {
2627

2728
task standalone(dependsOn: 'shadowJar') {
2829
doLast {
29-
if(!file("${buildDir}/avian").exists()){
30+
if (!file("${buildDir}/avian").exists()) {
3031
exec {
3132
commandLine 'git', 'clone', 'https://github.com/ReadyTalk/avian.git', "${buildDir}/avian"
3233
}
@@ -72,7 +73,7 @@ task standalone(dependsOn: 'shadowJar') {
7273
}
7374
exec {
7475
workingDir "${buildDir}/all"
75-
commandLine '/bin/bash', '-c', "/usr/local/bin/g++ -rdynamic *.o -ldl -lpthread -lz -o ${project.name} -framework CoreFoundation"
76+
commandLine '/bin/bash', '-c', "g++ -rdynamic *.o -ldl -lpthread -lz -o ${project.name} ${platform() == "macosx" ? '-framework CoreFoundation' : ''}"
7677
}
7778
exec {
7879
workingDir "${buildDir}/all"

build.gradle

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ buildscript {
1414
}
1515
repositories {
1616
mavenCentral()
17+
maven {
18+
url 'https://repository.jboss.org'
19+
}
1720
}
1821
dependencies {
1922
testCompile 'junit:junit:4.12'

gradle.properties

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#OPEN_JDK_PATH=/Users/isadykov/Library/Java/JavaVirtualMachines/jdk1.7.0.jdk/Contents/Home/
22
#OPEN_JDK_SRC_PATH=/Users/isadykov/dist/java/openjdk-1.7-src/jdk/src
3+
#OPEN_JDK_PATH=/usr/lib/jvm/java-7-openjdk-amd64
4+
#OPEN_JDK_SRC_PATH=/home/smecsia/dist/jdk/obuildfactory/sources/openjdk7/jdk/src
35
OPEN_JDK_PATH=
46
OPEN_JDK_SRC_PATH=
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Mon Nov 14 19:59:48 AEDT 2016
1+
#Fri Nov 18 11:50:45 AEDT 2016
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-all.zip

src/Main.kt

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import http.HttpHandler
12
import http.HttpHandler.Companion.httpHandler
23
import http.NioHttpServer
34

src/embedded-jar-main.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "jni.h"
2+
#include <stdint.h>
23
#include "stdlib.h"
34

45
#if (defined __MINGW32__) || (defined _MSC_VER)

src/http/NioHttpServer.kt

+7-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,13 @@ constructor(host: String = "0.0.0.0", port: Int = 8080,
4545
}
4646

4747
private fun dispatch(key: SelectionKey) {
48-
if (key.attachment() != null) {
49-
(key.attachment() as Runnable).run()
48+
when (key.attachment()) {
49+
is Acceptor -> {
50+
if (key.isAcceptable) {
51+
(key.attachment() as Acceptor).run()
52+
}
53+
}
54+
else -> (key.attachment() as Runnable).run()
5055
}
5156
}
5257

src/http/PooledHandler.kt

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ constructor(private val pool: ThreadPool,
3636
handler.handle(requestBuffer.array(), sw)
3737
socketChannel.write(wrap((sw.toString() as java.lang.String).bytes))
3838
}
39+
} else if(readCount < 0) {
40+
socketChannel.close()
3941
}
4042
}
4143

src/util/AbstractOwnableSynchronizer.java

-74
This file was deleted.

0 commit comments

Comments
 (0)