diff --git a/pom.xml b/pom.xml
index 932e8e6..053866a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
com.github.immueggpain
simple-streaming
- 0.0.8
+ 0.0.9
UTF-8
diff --git a/src/main/java/com/github/immueggpain/simplestreaming/Launcher.java b/src/main/java/com/github/immueggpain/simplestreaming/Launcher.java
index 6f50330..c2fadf0 100644
--- a/src/main/java/com/github/immueggpain/simplestreaming/Launcher.java
+++ b/src/main/java/com/github/immueggpain/simplestreaming/Launcher.java
@@ -11,7 +11,7 @@
subcommands = { HelpCommand.class, StreamUpload.class, StreamServer.class, Serve.class })
public class Launcher implements Callable {
- public static final String VERSTR = "0.0.8";
+ public static final String VERSTR = "0.0.9";
public static final int LOCAL_PORT = 2233;
public static final int LOCAL_OVPN_PORT = 1194;
public static final int BUFLEN = 1024 * 64;
diff --git a/src/main/java/com/github/immueggpain/simplestreaming/StreamServer.java b/src/main/java/com/github/immueggpain/simplestreaming/StreamServer.java
index 5ab30bd..336a97b 100644
--- a/src/main/java/com/github/immueggpain/simplestreaming/StreamServer.java
+++ b/src/main/java/com/github/immueggpain/simplestreaming/StreamServer.java
@@ -68,7 +68,7 @@ private void download_thread() {
private void download_thread(Socket socket) {
try (Socket socket_ = socket) {
OutputStream os = socket.getOutputStream();
- CircularByteBuffer buf = new CircularByteBuffer(Launcher.BUFLEN);
+ CircularByteBuffer buf = new CircularByteBuffer(Launcher.BUFLEN * 4);
byte[] bs = new byte[Launcher.BUFLEN];
// add me to active downloaders
@@ -94,6 +94,10 @@ private void download_thread(Socket socket) {
}
} catch (Exception e) {
e.printStackTrace();
+ } finally {
+ synchronized (activeDownloaders) {
+ activeDownloaders.remove(socket);
+ }
}
}
@@ -133,7 +137,8 @@ private void upload_thread(Socket socket) {
for (Downloader downloader : activeDownloaders.values()) {
int n = downloader.buf.put(buf, 0, len);
int missing = len - n;
- System.out.println("missing " + missing);
+ if (missing > 0)
+ System.out.println("missing " + missing);
}
}
}
@@ -147,7 +152,7 @@ private void remove_expired_player_thread() {
while (true) {
synchronized (activeDownloaders) {
long now = System.currentTimeMillis();
- System.out.println("==player check==" + now);
+ System.out.println("==downloader check==" + now);
for (Iterator> iterator = activeDownloaders.entrySet().iterator(); iterator
.hasNext();) {
Entry entry = iterator.next();
@@ -155,14 +160,14 @@ private void remove_expired_player_thread() {
Downloader playerInfo = entry.getValue();
long last = playerInfo.t;
if (now - last > 20000 && playerInfo.buf.available() > 0) {
- System.out.println(String.format("dead player: %s", key.getRemoteSocketAddress()));
+ System.out.println(String.format("dead downloader: %s", key.getRemoteSocketAddress()));
iterator.remove();
try {
key.close();
} catch (IOException e) {
}
} else {
- System.out.println(String.format("active player: %s", key.getRemoteSocketAddress()));
+ System.out.println(String.format("active downloader: %s", key.getRemoteSocketAddress()));
}
}
}