forked from I2P_Developers/i2p.i2p
2009-05-09 sponge
* fixed OOM on lock (woops! my bad!)
This commit is contained in:
@ -92,7 +92,7 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
|||||||
private final List tasks = new ArrayList();
|
private final List tasks = new ArrayList();
|
||||||
private int next_task_id = 1;
|
private int next_task_id = 1;
|
||||||
|
|
||||||
private Set listeners = new HashSet();
|
private final Set listeners = new HashSet();
|
||||||
|
|
||||||
public static void main(String[] args) throws IOException {
|
public static void main(String[] args) throws IOException {
|
||||||
new I2PTunnel(args);
|
new I2PTunnel(args);
|
||||||
@ -668,9 +668,9 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
|||||||
*/
|
*/
|
||||||
public void runConnectClient(String args[], Logging l) {
|
public void runConnectClient(String args[], Logging l) {
|
||||||
if (args.length >= 1 && args.length <= 3) {
|
if (args.length >= 1 && args.length <= 3) {
|
||||||
int port = -1;
|
int _port = -1;
|
||||||
try {
|
try {
|
||||||
port = Integer.parseInt(args[0]);
|
_port = Integer.parseInt(args[0]);
|
||||||
} catch (NumberFormatException nfe) {
|
} catch (NumberFormatException nfe) {
|
||||||
_log.error(getPrefix() + "Port specified is not valid: " + args[0], nfe);
|
_log.error(getPrefix() + "Port specified is not valid: " + args[0], nfe);
|
||||||
return;
|
return;
|
||||||
@ -702,10 +702,10 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
|||||||
I2PTunnelTask task;
|
I2PTunnelTask task;
|
||||||
ownDest = !isShared;
|
ownDest = !isShared;
|
||||||
try {
|
try {
|
||||||
task = new I2PTunnelConnectClient(port, l, ownDest, proxy, (EventDispatcher) this, this);
|
task = new I2PTunnelConnectClient(_port, l, ownDest, proxy, (EventDispatcher) this, this);
|
||||||
addtask(task);
|
addtask(task);
|
||||||
} catch (IllegalArgumentException iae) {
|
} catch (IllegalArgumentException iae) {
|
||||||
_log.error(getPrefix() + "Invalid I2PTunnel config to create an httpclient [" + host + ":"+ port + "]", iae);
|
_log.error(getPrefix() + "Invalid I2PTunnel config to create an httpclient [" + host + ":"+ _port + "]", iae);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
l.log("connectclient <port> [<sharedClient>] [<proxy>]");
|
l.log("connectclient <port> [<sharedClient>] [<proxy>]");
|
||||||
@ -728,9 +728,9 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
|||||||
*/
|
*/
|
||||||
public void runIrcClient(String args[], Logging l) {
|
public void runIrcClient(String args[], Logging l) {
|
||||||
if (args.length >= 2) {
|
if (args.length >= 2) {
|
||||||
int port = -1;
|
int _port = -1;
|
||||||
try {
|
try {
|
||||||
port = Integer.parseInt(args[0]);
|
_port = Integer.parseInt(args[0]);
|
||||||
} catch (NumberFormatException nfe) {
|
} catch (NumberFormatException nfe) {
|
||||||
l.log("invalid port");
|
l.log("invalid port");
|
||||||
_log.error(getPrefix() + "Port specified is not valid: " + args[0], nfe);
|
_log.error(getPrefix() + "Port specified is not valid: " + args[0], nfe);
|
||||||
@ -757,12 +757,12 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
|||||||
String privateKeyFile = null;
|
String privateKeyFile = null;
|
||||||
if (args.length >= 4)
|
if (args.length >= 4)
|
||||||
privateKeyFile = args[3];
|
privateKeyFile = args[3];
|
||||||
task = new I2PTunnelIRCClient(port, args[1], l, ownDest, (EventDispatcher) this, this, privateKeyFile);
|
task = new I2PTunnelIRCClient(_port, args[1], l, ownDest, (EventDispatcher) this, this, privateKeyFile);
|
||||||
addtask(task);
|
addtask(task);
|
||||||
notifyEvent("ircclientTaskId", Integer.valueOf(task.getId()));
|
notifyEvent("ircclientTaskId", Integer.valueOf(task.getId()));
|
||||||
} catch (IllegalArgumentException iae) {
|
} catch (IllegalArgumentException iae) {
|
||||||
_log.error(getPrefix() + "Invalid I2PTunnel config to create an ircclient [" + host + ":"+ port + "]", iae);
|
_log.error(getPrefix() + "Invalid I2PTunnel config to create an ircclient [" + host + ":"+ _port + "]", iae);
|
||||||
l.log("Invalid I2PTunnel configuration [" + host + ":" + port + "]");
|
l.log("Invalid I2PTunnel configuration [" + host + ":" + _port + "]");
|
||||||
notifyEvent("ircclientTaskId", Integer.valueOf(-1));
|
notifyEvent("ircclientTaskId", Integer.valueOf(-1));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -786,9 +786,9 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
|||||||
*/
|
*/
|
||||||
public void runSOCKSTunnel(String args[], Logging l) {
|
public void runSOCKSTunnel(String args[], Logging l) {
|
||||||
if (args.length >= 1 && args.length <= 2) {
|
if (args.length >= 1 && args.length <= 2) {
|
||||||
int port = -1;
|
int _port = -1;
|
||||||
try {
|
try {
|
||||||
port = Integer.parseInt(args[0]);
|
_port = Integer.parseInt(args[0]);
|
||||||
} catch (NumberFormatException nfe) {
|
} catch (NumberFormatException nfe) {
|
||||||
l.log("invalid port");
|
l.log("invalid port");
|
||||||
_log.error(getPrefix() + "Port specified is not valid: " + args[0], nfe);
|
_log.error(getPrefix() + "Port specified is not valid: " + args[0], nfe);
|
||||||
@ -802,7 +802,7 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
|||||||
|
|
||||||
ownDest = !isShared;
|
ownDest = !isShared;
|
||||||
I2PTunnelTask task;
|
I2PTunnelTask task;
|
||||||
task = new I2PSOCKSTunnel(port, l, ownDest, (EventDispatcher) this, this);
|
task = new I2PSOCKSTunnel(_port, l, ownDest, (EventDispatcher) this, this);
|
||||||
addtask(task);
|
addtask(task);
|
||||||
notifyEvent("sockstunnelTaskId", Integer.valueOf(task.getId()));
|
notifyEvent("sockstunnelTaskId", Integer.valueOf(task.getId()));
|
||||||
} else {
|
} else {
|
||||||
@ -820,9 +820,9 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
|||||||
*/
|
*/
|
||||||
public void runStreamrClient(String args[], Logging l) {
|
public void runStreamrClient(String args[], Logging l) {
|
||||||
if (args.length == 3) {
|
if (args.length == 3) {
|
||||||
InetAddress host;
|
InetAddress _host;
|
||||||
try {
|
try {
|
||||||
host = InetAddress.getByName(args[0]);
|
_host = InetAddress.getByName(args[0]);
|
||||||
} catch (UnknownHostException uhe) {
|
} catch (UnknownHostException uhe) {
|
||||||
l.log("unknown host");
|
l.log("unknown host");
|
||||||
_log.error(getPrefix() + "Error resolving " + args[0], uhe);
|
_log.error(getPrefix() + "Error resolving " + args[0], uhe);
|
||||||
@ -830,9 +830,9 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int port = -1;
|
int _port = -1;
|
||||||
try {
|
try {
|
||||||
port = Integer.parseInt(args[1]);
|
_port = Integer.parseInt(args[1]);
|
||||||
} catch (NumberFormatException nfe) {
|
} catch (NumberFormatException nfe) {
|
||||||
l.log("invalid port");
|
l.log("invalid port");
|
||||||
_log.error(getPrefix() + "Port specified is not valid: " + args[0], nfe);
|
_log.error(getPrefix() + "Port specified is not valid: " + args[0], nfe);
|
||||||
@ -840,7 +840,7 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
StreamrConsumer task = new StreamrConsumer(host, port, args[2], l, (EventDispatcher) this, this);
|
StreamrConsumer task = new StreamrConsumer(_host, _port, args[2], l, (EventDispatcher) this, this);
|
||||||
task.startRunning();
|
task.startRunning();
|
||||||
addtask(task);
|
addtask(task);
|
||||||
notifyEvent("streamrtunnelTaskId", Integer.valueOf(task.getId()));
|
notifyEvent("streamrtunnelTaskId", Integer.valueOf(task.getId()));
|
||||||
@ -859,9 +859,9 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
|||||||
*/
|
*/
|
||||||
public void runStreamrServer(String args[], Logging l) {
|
public void runStreamrServer(String args[], Logging l) {
|
||||||
if (args.length == 2) {
|
if (args.length == 2) {
|
||||||
int port = -1;
|
int _port = -1;
|
||||||
try {
|
try {
|
||||||
port = Integer.parseInt(args[0]);
|
_port = Integer.parseInt(args[0]);
|
||||||
} catch (NumberFormatException nfe) {
|
} catch (NumberFormatException nfe) {
|
||||||
l.log("invalid port");
|
l.log("invalid port");
|
||||||
_log.error(getPrefix() + "Port specified is not valid: " + args[0], nfe);
|
_log.error(getPrefix() + "Port specified is not valid: " + args[0], nfe);
|
||||||
@ -877,7 +877,7 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
StreamrProducer task = new StreamrProducer(port, privKeyFile, args[1], l, (EventDispatcher) this, this);
|
StreamrProducer task = new StreamrProducer(_port, privKeyFile, args[1], l, (EventDispatcher) this, this);
|
||||||
task.startRunning();
|
task.startRunning();
|
||||||
addtask(task);
|
addtask(task);
|
||||||
notifyEvent("streamrtunnelTaskId", Integer.valueOf(task.getId()));
|
notifyEvent("streamrtunnelTaskId", Integer.valueOf(task.getId()));
|
||||||
|
@ -200,9 +200,9 @@ class I2PSessionMuxedImpl extends I2PSessionImpl2 implements I2PSession {
|
|||||||
|
|
||||||
protected class MuxedAvailabilityNotifier extends AvailabilityNotifier {
|
protected class MuxedAvailabilityNotifier extends AvailabilityNotifier {
|
||||||
private LinkedBlockingQueue<MsgData> _msgs;
|
private LinkedBlockingQueue<MsgData> _msgs;
|
||||||
private AtomicBoolean _alive = new AtomicBoolean(false);
|
private volatile Boolean _alive = new Boolean(false);
|
||||||
private static final int POISON_SIZE = -99999;
|
private static final int POISON_SIZE = -99999;
|
||||||
private AtomicBoolean stopping = new AtomicBoolean(false);
|
private final AtomicBoolean stopping = new AtomicBoolean(false);
|
||||||
|
|
||||||
public MuxedAvailabilityNotifier() {
|
public MuxedAvailabilityNotifier() {
|
||||||
_msgs = new LinkedBlockingQueue();
|
_msgs = new LinkedBlockingQueue();
|
||||||
@ -210,28 +210,29 @@ class I2PSessionMuxedImpl extends I2PSessionImpl2 implements I2PSession {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stopNotifying() {
|
public void stopNotifying() {
|
||||||
if(stopping.get()) return;
|
|
||||||
stopping.set(true);
|
|
||||||
boolean again = true;
|
boolean again = true;
|
||||||
// _msgs.clear();
|
synchronized (stopping) {
|
||||||
// Thread.yield();
|
if(!stopping.get()) {
|
||||||
if (_alive.get()) {
|
stopping.set(true);
|
||||||
// System.out.println("I2PSessionMuxedImpl.stopNotifying()");
|
if (_alive.equals(true)) {
|
||||||
_msgs.clear();
|
// System.out.println("I2PSessionMuxedImpl.stopNotifying()");
|
||||||
while(again) {
|
_msgs.clear();
|
||||||
try {
|
while(again) {
|
||||||
_msgs.put(new MsgData(0, POISON_SIZE, 0, 0, 0));
|
try {
|
||||||
again = false;
|
_msgs.put(new MsgData(0, POISON_SIZE, 0, 0, 0));
|
||||||
// System.out.println("I2PSessionMuxedImpl.stopNotifying() success.");
|
again = false;
|
||||||
} catch (InterruptedException ie) {
|
// System.out.println("I2PSessionMuxedImpl.stopNotifying() success.");
|
||||||
continue;
|
} catch (InterruptedException ie) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
_alive = false;
|
||||||
|
stopping.set(false);
|
||||||
}
|
}
|
||||||
|
stopping.notifyAll();
|
||||||
}
|
}
|
||||||
_alive.set(false);
|
|
||||||
stopping.set(false); // Do we need this?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** unused */
|
/** unused */
|
||||||
@Override
|
@Override
|
||||||
public void available(long msgId, int size) { throw new IllegalArgumentException("no"); }
|
public void available(long msgId, int size) { throw new IllegalArgumentException("no"); }
|
||||||
@ -245,8 +246,8 @@ class I2PSessionMuxedImpl extends I2PSessionImpl2 implements I2PSession {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
MsgData msg;
|
MsgData msg;
|
||||||
_alive.set(true);
|
_alive=true;
|
||||||
while (_alive.get()) {
|
while (_alive) {
|
||||||
try {
|
try {
|
||||||
msg = _msgs.take();
|
msg = _msgs.take();
|
||||||
} catch (InterruptedException ie) {
|
} catch (InterruptedException ie) {
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
2009-05-09 sponge
|
||||||
|
* fixed OOM on lock (woops! my bad!)
|
||||||
|
|
||||||
2009-05-08 Mathiasdm
|
2009-05-08 Mathiasdm
|
||||||
* desktopgui: moved files to stop polluting the namespace
|
* desktopgui: moved files to stop polluting the namespace
|
||||||
(everything now in net.i2p.desktopgui)
|
(everything now in net.i2p.desktopgui)
|
||||||
|
@ -18,7 +18,7 @@ public class RouterVersion {
|
|||||||
/** deprecated */
|
/** deprecated */
|
||||||
public final static String ID = "Monotone";
|
public final static String ID = "Monotone";
|
||||||
public final static String VERSION = CoreVersion.VERSION;
|
public final static String VERSION = CoreVersion.VERSION;
|
||||||
public final static long BUILD = 10;
|
public final static long BUILD = 11;
|
||||||
/** for example "-test" */
|
/** for example "-test" */
|
||||||
public final static String EXTRA = "";
|
public final static String EXTRA = "";
|
||||||
public final static String FULL_VERSION = VERSION + "-" + BUILD + EXTRA;
|
public final static String FULL_VERSION = VERSION + "-" + BUILD + EXTRA;
|
||||||
|
Reference in New Issue
Block a user