forked from I2P_Developers/i2p.i2p
Convert remaining Threads to I2PThread or I2PAppThread
This commit is contained in:
@ -338,7 +338,7 @@ public class BOB implements Runnable, ClientApp {
|
|||||||
|
|
||||||
if (g) {
|
if (g) {
|
||||||
DoCMDS conn_c = new DoCMDS(spin, lock, server, props, database, _log);
|
DoCMDS conn_c = new DoCMDS(spin, lock, server, props, database, _log);
|
||||||
Thread t = new Thread(conn_c);
|
Thread t = new I2PAppThread(conn_c);
|
||||||
t.setName("BOB.DoCMDS " + i);
|
t.setName("BOB.DoCMDS " + i);
|
||||||
t.start();
|
t.start();
|
||||||
i++;
|
i++;
|
||||||
|
@ -25,12 +25,13 @@ import java.util.Locale;
|
|||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import net.i2p.I2PAppContext;
|
import net.i2p.I2PAppContext;
|
||||||
import net.i2p.I2PException;
|
import net.i2p.I2PException;
|
||||||
import net.i2p.client.I2PClientFactory;
|
import net.i2p.client.I2PClientFactory;
|
||||||
//import net.i2p.data.DataFormatException;
|
|
||||||
import net.i2p.data.Destination;
|
import net.i2p.data.Destination;
|
||||||
//import net.i2p.i2ptunnel.I2PTunnel;
|
import net.i2p.util.I2PAppThread;
|
||||||
|
|
||||||
// needed only for debugging.
|
// needed only for debugging.
|
||||||
// import java.util.logging.Level;
|
// import java.util.logging.Level;
|
||||||
// import java.util.logging.Logger;
|
// import java.util.logging.Logger;
|
||||||
@ -1307,7 +1308,7 @@ public class DoCMDS implements Runnable {
|
|||||||
// wait
|
// wait
|
||||||
}
|
}
|
||||||
tunnel = new MUXlisten(lock, database, nickinfo, _log);
|
tunnel = new MUXlisten(lock, database, nickinfo, _log);
|
||||||
Thread t = new Thread(tunnel);
|
Thread t = new I2PAppThread(tunnel);
|
||||||
t.start();
|
t.start();
|
||||||
// try {
|
// try {
|
||||||
// Thread.sleep(1000 * 10); // Slow down the startup.
|
// Thread.sleep(1000 * 10); // Slow down the startup.
|
||||||
|
@ -18,10 +18,12 @@ package net.i2p.BOB;
|
|||||||
import java.net.ConnectException;
|
import java.net.ConnectException;
|
||||||
import java.net.SocketTimeoutException;
|
import java.net.SocketTimeoutException;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import net.i2p.I2PException;
|
import net.i2p.I2PException;
|
||||||
import net.i2p.client.streaming.I2PServerSocket;
|
import net.i2p.client.streaming.I2PServerSocket;
|
||||||
import net.i2p.client.streaming.I2PSocket;
|
import net.i2p.client.streaming.I2PSocket;
|
||||||
import net.i2p.client.streaming.I2PSocketManager;
|
import net.i2p.client.streaming.I2PSocketManager;
|
||||||
|
import net.i2p.util.I2PAppThread;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Listen on I2P and connect to TCP
|
* Listen on I2P and connect to TCP
|
||||||
@ -77,7 +79,7 @@ public class I2Plistener implements Runnable {
|
|||||||
conn++;
|
conn++;
|
||||||
// toss the connection to a new thread.
|
// toss the connection to a new thread.
|
||||||
I2PtoTCP conn_c = new I2PtoTCP(sessSocket, info, database, lives);
|
I2PtoTCP conn_c = new I2PtoTCP(sessSocket, info, database, lives);
|
||||||
Thread t = new Thread(conn_c, Thread.currentThread().getName() + " I2PtoTCP " + conn);
|
Thread t = new I2PAppThread(conn_c, Thread.currentThread().getName() + " I2PtoTCP " + conn);
|
||||||
t.start();
|
t.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,9 @@ import java.io.InputStream;
|
|||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import net.i2p.client.streaming.I2PSocket;
|
import net.i2p.client.streaming.I2PSocket;
|
||||||
|
import net.i2p.util.I2PAppThread;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process I2P->TCP
|
* Process I2P->TCP
|
||||||
@ -111,8 +113,8 @@ public class I2PtoTCP implements Runnable {
|
|||||||
// setup to cross the streams
|
// setup to cross the streams
|
||||||
TCPio conn_c = new TCPio(in, Iout, lives); // app -> I2P
|
TCPio conn_c = new TCPio(in, Iout, lives); // app -> I2P
|
||||||
TCPio conn_a = new TCPio(Iin, out, lives); // I2P -> app
|
TCPio conn_a = new TCPio(Iin, out, lives); // I2P -> app
|
||||||
t = new Thread(conn_c, Thread.currentThread().getName() + " TCPioA");
|
t = new I2PAppThread(conn_c, Thread.currentThread().getName() + " TCPioA");
|
||||||
q = new Thread(conn_a, Thread.currentThread().getName() + " TCPioB");
|
q = new I2PAppThread(conn_a, Thread.currentThread().getName() + " TCPioB");
|
||||||
// Fire!
|
// Fire!
|
||||||
t.start();
|
t.start();
|
||||||
q.start();
|
q.start();
|
||||||
|
@ -21,11 +21,13 @@ import java.net.InetAddress;
|
|||||||
import java.net.ServerSocket;
|
import java.net.ServerSocket;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import net.i2p.I2PException;
|
import net.i2p.I2PException;
|
||||||
import net.i2p.client.I2PClient;
|
import net.i2p.client.I2PClient;
|
||||||
import net.i2p.client.streaming.I2PServerSocket;
|
import net.i2p.client.streaming.I2PServerSocket;
|
||||||
import net.i2p.client.streaming.I2PSocketManager;
|
import net.i2p.client.streaming.I2PSocketManager;
|
||||||
import net.i2p.client.streaming.I2PSocketManagerFactory;
|
import net.i2p.client.streaming.I2PSocketManagerFactory;
|
||||||
|
import net.i2p.util.I2PAppThread;
|
||||||
import net.i2p.util.Log;
|
import net.i2p.util.Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -201,14 +203,14 @@ public class MUXlisten implements Runnable {
|
|||||||
// I2P -> TCP
|
// I2P -> TCP
|
||||||
SS = socketManager.getServerSocket();
|
SS = socketManager.getServerSocket();
|
||||||
I2Plistener conn = new I2Plistener(SS, socketManager, info, database, _log, lives);
|
I2Plistener conn = new I2Plistener(SS, socketManager, info, database, _log, lives);
|
||||||
t = new Thread(tg, conn, "BOBI2Plistener " + N);
|
t = new I2PAppThread(tg, conn, "BOBI2Plistener " + N);
|
||||||
t.start();
|
t.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (come_in) {
|
if (come_in) {
|
||||||
// TCP -> I2P
|
// TCP -> I2P
|
||||||
TCPlistener conn = new TCPlistener(listener, socketManager, info, database, _log, lives);
|
TCPlistener conn = new TCPlistener(listener, socketManager, info, database, _log, lives);
|
||||||
q = new Thread(tg, conn, "BOBTCPlistener " + N);
|
q = new I2PAppThread(tg, conn, "BOBTCPlistener " + N);
|
||||||
q.start();
|
q.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,8 +20,10 @@ import java.net.ServerSocket;
|
|||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.net.SocketTimeoutException;
|
import java.net.SocketTimeoutException;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import net.i2p.client.streaming.I2PServerSocket;
|
import net.i2p.client.streaming.I2PServerSocket;
|
||||||
import net.i2p.client.streaming.I2PSocketManager;
|
import net.i2p.client.streaming.I2PSocketManager;
|
||||||
|
import net.i2p.util.I2PAppThread;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Listen on TCP port and connect to I2P
|
* Listen on TCP port and connect to I2P
|
||||||
@ -75,7 +77,7 @@ public class TCPlistener implements Runnable {
|
|||||||
conn++;
|
conn++;
|
||||||
// toss the connection to a new thread.
|
// toss the connection to a new thread.
|
||||||
TCPtoI2P conn_c = new TCPtoI2P(socketManager, server, info, database, lives);
|
TCPtoI2P conn_c = new TCPtoI2P(socketManager, server, info, database, lives);
|
||||||
Thread t = new Thread(conn_c, Thread.currentThread().getName() + " TCPtoI2P " + conn);
|
Thread t = new I2PAppThread(conn_c, Thread.currentThread().getName() + " TCPtoI2P " + conn);
|
||||||
t.start();
|
t.start();
|
||||||
g = false;
|
g = false;
|
||||||
}
|
}
|
||||||
|
@ -24,13 +24,14 @@ import java.net.NoRouteToHostException;
|
|||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
|
import net.i2p.I2PAppContext;
|
||||||
import net.i2p.I2PException;
|
import net.i2p.I2PException;
|
||||||
import net.i2p.client.streaming.I2PSocket;
|
import net.i2p.client.streaming.I2PSocket;
|
||||||
import net.i2p.client.streaming.I2PSocketManager;
|
import net.i2p.client.streaming.I2PSocketManager;
|
||||||
import net.i2p.data.DataFormatException;
|
import net.i2p.data.DataFormatException;
|
||||||
import net.i2p.data.Destination;
|
import net.i2p.data.Destination;
|
||||||
//import net.i2p.i2ptunnel.I2PTunnel;
|
import net.i2p.util.I2PAppThread;
|
||||||
import net.i2p.I2PAppContext;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -158,8 +159,8 @@ public class TCPtoI2P implements Runnable {
|
|||||||
// setup to cross the streams
|
// setup to cross the streams
|
||||||
TCPio conn_c = new TCPio(in, Iout, lives); // app -> I2P
|
TCPio conn_c = new TCPio(in, Iout, lives); // app -> I2P
|
||||||
TCPio conn_a = new TCPio(Iin, out, lives); // I2P -> app
|
TCPio conn_a = new TCPio(Iin, out, lives); // I2P -> app
|
||||||
t = new Thread(conn_c, Thread.currentThread().getName() + " TCPioA");
|
t = new I2PAppThread(conn_c, Thread.currentThread().getName() + " TCPioA");
|
||||||
q = new Thread(conn_a, Thread.currentThread().getName() + " TCPioB");
|
q = new I2PAppThread(conn_a, Thread.currentThread().getName() + " TCPioB");
|
||||||
// Fire!
|
// Fire!
|
||||||
t.start();
|
t.start();
|
||||||
q.start();
|
q.start();
|
||||||
|
@ -119,10 +119,10 @@ class SAMv3StreamSession extends SAMStreamSession implements SAMv3Handler.Sessi
|
|||||||
WritableByteChannel toI2P = Channels.newChannel(i2ps.getOutputStream());
|
WritableByteChannel toI2P = Channels.newChannel(i2ps.getOutputStream());
|
||||||
|
|
||||||
SAMBridge bridge = handler.getBridge();
|
SAMBridge bridge = handler.getBridge();
|
||||||
(new Thread(rec.getThreadGroup(),
|
(new I2PAppThread(rec.getThreadGroup(),
|
||||||
new Pipe(fromClient, toI2P, bridge),
|
new Pipe(fromClient, toI2P, bridge),
|
||||||
"ConnectV3 SAMPipeClientToI2P")).start();
|
"ConnectV3 SAMPipeClientToI2P")).start();
|
||||||
(new Thread(rec.getThreadGroup(),
|
(new I2PAppThread(rec.getThreadGroup(),
|
||||||
new Pipe(fromI2P, toClient, bridge),
|
new Pipe(fromI2P, toClient, bridge),
|
||||||
"ConnectV3 SAMPipeI2PToClient")).start();
|
"ConnectV3 SAMPipeI2PToClient")).start();
|
||||||
}
|
}
|
||||||
@ -176,10 +176,10 @@ class SAMv3StreamSession extends SAMStreamSession implements SAMv3Handler.Sessi
|
|||||||
WritableByteChannel toI2P = Channels.newChannel(i2ps.getOutputStream());
|
WritableByteChannel toI2P = Channels.newChannel(i2ps.getOutputStream());
|
||||||
|
|
||||||
SAMBridge bridge = handler.getBridge();
|
SAMBridge bridge = handler.getBridge();
|
||||||
(new Thread(rec.getThreadGroup(),
|
(new I2PAppThread(rec.getThreadGroup(),
|
||||||
new Pipe(fromClient, toI2P, bridge),
|
new Pipe(fromClient, toI2P, bridge),
|
||||||
"AcceptV3 SAMPipeClientToI2P")).start();
|
"AcceptV3 SAMPipeClientToI2P")).start();
|
||||||
(new Thread(rec.getThreadGroup(),
|
(new I2PAppThread(rec.getThreadGroup(),
|
||||||
new Pipe(fromI2P, toClient, bridge),
|
new Pipe(fromI2P, toClient, bridge),
|
||||||
"AcceptV3 SAMPipeI2PToClient")).start();
|
"AcceptV3 SAMPipeI2PToClient")).start();
|
||||||
}
|
}
|
||||||
@ -219,7 +219,7 @@ class SAMv3StreamSession extends SAMStreamSession implements SAMv3Handler.Sessi
|
|||||||
}
|
}
|
||||||
|
|
||||||
SocketForwarder forwarder = new SocketForwarder(host, port, this, verbose);
|
SocketForwarder forwarder = new SocketForwarder(host, port, this, verbose);
|
||||||
(new Thread(rec.getThreadGroup(), forwarder, "SAMV3StreamForwarder")).start();
|
(new I2PAppThread(rec.getThreadGroup(), forwarder, "SAMV3StreamForwarder")).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class SocketForwarder implements Runnable
|
private static class SocketForwarder implements Runnable
|
||||||
|
@ -38,10 +38,18 @@ public class I2PAppThread extends I2PThread {
|
|||||||
public I2PAppThread(Runnable r, String name) {
|
public I2PAppThread(Runnable r, String name) {
|
||||||
super(r, name);
|
super(r, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public I2PAppThread(Runnable r, String name, boolean isDaemon) {
|
public I2PAppThread(Runnable r, String name, boolean isDaemon) {
|
||||||
super(r, name, isDaemon);
|
super(r, name, isDaemon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 0.9.23
|
||||||
|
*/
|
||||||
|
public I2PAppThread(ThreadGroup group, Runnable r, String name) {
|
||||||
|
super(group, r, name);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void fireOOM(OutOfMemoryError oom) {
|
protected void fireOOM(OutOfMemoryError oom) {
|
||||||
for (OOMEventListener listener : _threadListeners)
|
for (OOMEventListener listener : _threadListeners)
|
||||||
|
@ -73,6 +73,14 @@ public class I2PThread extends Thread {
|
|||||||
// _createdBy = new Exception("Created by");
|
// _createdBy = new Exception("Created by");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 0.9.23
|
||||||
|
*/
|
||||||
|
public I2PThread(ThreadGroup group, Runnable r, String name) {
|
||||||
|
super(group, r, name);
|
||||||
|
setPriority(NORM_PRIORITY);
|
||||||
|
}
|
||||||
|
|
||||||
/****
|
/****
|
||||||
private void log(int level, String msg) { log(level, msg, null); }
|
private void log(int level, String msg) { log(level, msg, null); }
|
||||||
|
|
||||||
|
@ -1141,7 +1141,7 @@ public class Router implements RouterClock.ClockShiftListener {
|
|||||||
_log.warn("Running shutdown task " + task.getClass());
|
_log.warn("Running shutdown task " + task.getClass());
|
||||||
try {
|
try {
|
||||||
//task.run();
|
//task.run();
|
||||||
Thread t = new Thread(task, "Shutdown task " + task.getClass().getName());
|
Thread t = new I2PAppThread(task, "Shutdown task " + task.getClass().getName());
|
||||||
t.setDaemon(true);
|
t.setDaemon(true);
|
||||||
t.start();
|
t.start();
|
||||||
try {
|
try {
|
||||||
@ -1454,7 +1454,7 @@ public class Router implements RouterClock.ClockShiftListener {
|
|||||||
((RouterClock) _context.clock()).removeShiftListener(this);
|
((RouterClock) _context.clock()).removeShiftListener(this);
|
||||||
// Let's not stop accepting tunnels, etc
|
// Let's not stop accepting tunnels, etc
|
||||||
//_started = _context.clock().now();
|
//_started = _context.clock().now();
|
||||||
Thread t = new Thread(new Restarter(_context), "Router Restart");
|
Thread t = new I2PThread(new Restarter(_context), "Router Restart");
|
||||||
t.setPriority(Thread.NORM_PRIORITY + 1);
|
t.setPriority(Thread.NORM_PRIORITY + 1);
|
||||||
t.start();
|
t.start();
|
||||||
}
|
}
|
||||||
|
@ -165,7 +165,7 @@ class PeerManager {
|
|||||||
* @since 0.8.8
|
* @since 0.8.8
|
||||||
*/
|
*/
|
||||||
private void loadProfilesInBackground() {
|
private void loadProfilesInBackground() {
|
||||||
(new Thread(new ProfileLoader())).start();
|
(new I2PThread(new ProfileLoader())).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,6 +19,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
import net.i2p.I2PAppContext;
|
import net.i2p.I2PAppContext;
|
||||||
import net.i2p.data.DataHelper;
|
import net.i2p.data.DataHelper;
|
||||||
import net.i2p.util.Addresses;
|
import net.i2p.util.Addresses;
|
||||||
|
import net.i2p.util.I2PThread;
|
||||||
import net.i2p.util.Log;
|
import net.i2p.util.Log;
|
||||||
import net.i2p.util.Translate;
|
import net.i2p.util.Translate;
|
||||||
|
|
||||||
@ -994,7 +995,7 @@ class UPnP extends ControlPoint implements DeviceChangeListener, EventListener {
|
|||||||
}
|
}
|
||||||
if (_log.shouldLog(Log.INFO))
|
if (_log.shouldLog(Log.INFO))
|
||||||
_log.info("Starting thread to forward " + portsToForwardNow.size() + " ports");
|
_log.info("Starting thread to forward " + portsToForwardNow.size() + " ports");
|
||||||
Thread t = new Thread(new RegisterPortsThread(portsToForwardNow));
|
Thread t = new I2PThread(new RegisterPortsThread(portsToForwardNow));
|
||||||
t.setName("UPnP Port Opener " + __id.incrementAndGet());
|
t.setName("UPnP Port Opener " + __id.incrementAndGet());
|
||||||
t.setDaemon(true);
|
t.setDaemon(true);
|
||||||
t.start();
|
t.start();
|
||||||
@ -1034,7 +1035,7 @@ class UPnP extends ControlPoint implements DeviceChangeListener, EventListener {
|
|||||||
private void unregisterPorts(Set<ForwardPort> portsToForwardNow) {
|
private void unregisterPorts(Set<ForwardPort> portsToForwardNow) {
|
||||||
if (_log.shouldLog(Log.INFO))
|
if (_log.shouldLog(Log.INFO))
|
||||||
_log.info("Starting thread to un-forward " + portsToForwardNow.size() + " ports");
|
_log.info("Starting thread to un-forward " + portsToForwardNow.size() + " ports");
|
||||||
Thread t = new Thread(new UnregisterPortsThread(portsToForwardNow));
|
Thread t = new I2PThread(new UnregisterPortsThread(portsToForwardNow));
|
||||||
t.setName("UPnP Port Closer " + __id.incrementAndGet());
|
t.setName("UPnP Port Closer " + __id.incrementAndGet());
|
||||||
t.setDaemon(true);
|
t.setDaemon(true);
|
||||||
t.start();
|
t.start();
|
||||||
|
Reference in New Issue
Block a user