use of net.i2p.util.I2PAppThread in project i2p.i2p by i2p.
the class Reseeder method requestReseed.
/**
* Start a reseed using the default reseed URLs.
* Supports su3 and directories.
* Threaded, nonblocking.
*/
void requestReseed() {
ReseedRunner reseedRunner = new ReseedRunner();
// set to daemon so it doesn't hang a shutdown
Thread reseed = new I2PAppThread(reseedRunner, "Reseed", true);
reseed.start();
}
use of net.i2p.util.I2PAppThread in project i2p.i2p by i2p.
the class I2PSOCKSIRCTunnel method clientConnectionRun.
/**
* Same as in I2PSOCKSTunnel, but run the filters from I2PTunnelIRCClient
* instead of I2PTunnelRunner
*/
@Override
protected void clientConnectionRun(Socket s) {
I2PSocket destSock = null;
try {
// _log.error("SOCKS IRC Tunnel Start");
try {
s.setSoTimeout(INITIAL_SO_TIMEOUT);
} catch (SocketException ioe) {
}
SOCKSServer serv = SOCKSServerFactory.createSOCKSServer(_context, s, getTunnel().getClientOptions());
Socket clientSock = serv.getClientSocket();
try {
s.setSoTimeout(0);
} catch (SocketException ioe) {
}
destSock = serv.getDestinationI2PSocket(this);
StringBuffer expectedPong = new StringBuffer();
int id = __clientId.incrementAndGet();
Thread in = new I2PAppThread(new IrcInboundFilter(clientSock, destSock, expectedPong, _log), "SOCKS IRC Client " + id + " in", true);
in.start();
// Thread out = new I2PAppThread(new IrcOutboundFilter(clientSock, destSock, expectedPong, _log),
// "SOCKS IRC Client " + id + " out", true);
Runnable out = new IrcOutboundFilter(clientSock, destSock, expectedPong, _log);
// we are called from an unlimited thread pool, so run inline
// out.start();
out.run();
} catch (SOCKSException e) {
if (_log.shouldLog(Log.WARN))
_log.warn("Error from SOCKS connection", e);
} finally {
// only because we are running it inline
closeSocket(s);
if (destSock != null)
try {
destSock.close();
} catch (IOException ioe) {
}
}
}
use of net.i2p.util.I2PAppThread in project i2p.i2p by i2p.
the class WebMail method processGenericButtons.
/**
* @param sessionObject
* @param request
* @return new state
*/
private static State processGenericButtons(SessionObject sessionObject, RequestWrapper request, State state) {
/**
** All RELOAD buttons are commented out
* if( buttonPressed( request, RELOAD ) ) {
* Config.reloadConfiguration();
* int oldPageSize = sessionObject.folder.getPageSize();
* int pageSize = Config.getProperty( Folder.PAGESIZE, Folder.DEFAULT_PAGESIZE );
* if( pageSize != oldPageSize )
* sessionObject.folder.setPageSize( pageSize );
* sessionObject.info = _t("Configuration reloaded");
* }
***
*/
if (buttonPressed(request, REFRESH)) {
POP3MailBox mailbox = sessionObject.mailbox;
if (mailbox == null) {
sessionObject.error += _t("Internal error, lost connection.") + '\n';
return State.AUTH;
}
if (sessionObject.isFetching) {
// shouldn't happen, button disabled
return state;
}
sessionObject.isFetching = true;
ConnectWaiter cw = new ConnectWaiter(sessionObject);
if (mailbox.connectToServer(cw)) {
// Start a thread to wait for results
Debug.debug(Debug.DEBUG, "Already connected, running CW");
Thread t = new I2PAppThread(cw, "Email fetcher");
t.start();
} else {
sessionObject.error += _t("Cannot connect") + '\n';
sessionObject.isFetching = false;
}
// wait if it's going to be quick
try {
sessionObject.wait(3000);
} catch (InterruptedException ie) {
Debug.debug(Debug.DEBUG, "Interrupted waiting for connect", ie);
}
}
return state;
}
use of net.i2p.util.I2PAppThread in project i2p.i2p by i2p.
the class MailCache method loadFromDisk.
/**
* Threaded. Returns immediately.
* This will not access the mailbox. Mailbox need not be ready.
*
* @return success false if in progress already and nml will NOT be called back, true if nml will be called back
* @since 0.9.13
*/
public synchronized boolean loadFromDisk(NewMailListener nml) {
if (_loadInProgress != null)
return false;
Thread t = new I2PAppThread(new LoadMailRunner(nml), "Email loader");
_loadInProgress = nml;
try {
t.start();
} catch (Throwable e) {
_loadInProgress = null;
return false;
}
return true;
}
use of net.i2p.util.I2PAppThread in project i2p.i2p by i2p.
the class I2PTunnelClientBase method startup.
private void startup() {
if (_log.shouldLog(Log.DEBUG))
_log.debug("startup " + _clientId, new Exception("I did it"));
// prevent JVM exit when running outside the router
boolean isDaemon = getTunnel().getContext().isRouterContext();
open = true;
Thread t = new I2PAppThread(this, "I2PTunnel Client " + getTunnel().listenHost + ':' + localPort, isDaemon);
t.start();
synchronized (this) {
while (!listenerReady && open) {
try {
wait();
} catch (InterruptedException e) {
// ignore
}
}
}
if (open && listenerReady) {
boolean openNow = !Boolean.parseBoolean(getTunnel().getClientOptions().getProperty("i2cp.delayOpen"));
if (openNow || chained)
l.log("Client ready, listening on " + getTunnel().listenHost + ':' + localPort);
else
l.log("Client ready, listening on " + getTunnel().listenHost + ':' + localPort + ", delaying tunnel open until required");
notifyEvent("openBaseClientResult", "ok");
} else {
l.log("Client error for " + getTunnel().listenHost + ':' + localPort + ", check logs");
notifyEvent("openBaseClientResult", "error");
}
synchronized (startLock) {
startRunning = true;
startLock.notify();
}
}
Aggregations