Try again to prevent two EventPumpers
This commit is contained in:
@ -31,7 +31,7 @@ import net.i2p.util.Log;
|
|||||||
public class EventPumper implements Runnable {
|
public class EventPumper implements Runnable {
|
||||||
private RouterContext _context;
|
private RouterContext _context;
|
||||||
private Log _log;
|
private Log _log;
|
||||||
private boolean _alive;
|
private volatile boolean _alive;
|
||||||
private Selector _selector;
|
private Selector _selector;
|
||||||
private final List _bufCache;
|
private final List _bufCache;
|
||||||
private final List _wantsRead = new ArrayList(16);
|
private final List _wantsRead = new ArrayList(16);
|
||||||
@ -64,7 +64,7 @@ public class EventPumper implements Runnable {
|
|||||||
_expireIdleWriteTime = MAX_EXPIRE_IDLE_TIME;
|
_expireIdleWriteTime = MAX_EXPIRE_IDLE_TIME;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startPumping() {
|
public synchronized void startPumping() {
|
||||||
if (_log.shouldLog(Log.INFO))
|
if (_log.shouldLog(Log.INFO))
|
||||||
_log.info("Starting pumper");
|
_log.info("Starting pumper");
|
||||||
// _wantsRead = new ArrayList(16);
|
// _wantsRead = new ArrayList(16);
|
||||||
@ -83,7 +83,7 @@ public class EventPumper implements Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopPumping() {
|
public synchronized void stopPumping() {
|
||||||
_alive = false;
|
_alive = false;
|
||||||
if (_selector != null && _selector.isOpen())
|
if (_selector != null && _selector.isOpen())
|
||||||
_selector.wakeup();
|
_selector.wakeup();
|
||||||
|
@ -416,7 +416,7 @@ public class NTCPTransport extends TransportImpl {
|
|||||||
private static final int NUM_CONCURRENT_READERS = 3;
|
private static final int NUM_CONCURRENT_READERS = 3;
|
||||||
private static final int NUM_CONCURRENT_WRITERS = 3;
|
private static final int NUM_CONCURRENT_WRITERS = 3;
|
||||||
|
|
||||||
public RouterAddress startListening() {
|
public synchronized RouterAddress startListening() {
|
||||||
if (_log.shouldLog(Log.DEBUG)) _log.debug("Starting ntcp transport listening");
|
if (_log.shouldLog(Log.DEBUG)) _log.debug("Starting ntcp transport listening");
|
||||||
_finisher.start();
|
_finisher.start();
|
||||||
_pumper.startPumping();
|
_pumper.startPumping();
|
||||||
@ -428,7 +428,7 @@ public class NTCPTransport extends TransportImpl {
|
|||||||
return bindAddress();
|
return bindAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
public RouterAddress restartListening(RouterAddress addr) {
|
public synchronized RouterAddress restartListening(RouterAddress addr) {
|
||||||
if (_log.shouldLog(Log.DEBUG)) _log.debug("Restarting ntcp transport listening");
|
if (_log.shouldLog(Log.DEBUG)) _log.debug("Restarting ntcp transport listening");
|
||||||
_finisher.start();
|
_finisher.start();
|
||||||
_pumper.startPumping();
|
_pumper.startPumping();
|
||||||
@ -602,7 +602,7 @@ public class NTCPTransport extends TransportImpl {
|
|||||||
* This doesn't (completely) block, caller should check isAlive()
|
* This doesn't (completely) block, caller should check isAlive()
|
||||||
* before calling startListening() or restartListening()
|
* before calling startListening() or restartListening()
|
||||||
*/
|
*/
|
||||||
public void stopListening() {
|
public synchronized void stopListening() {
|
||||||
if (_log.shouldLog(Log.DEBUG)) _log.debug("Stopping ntcp transport");
|
if (_log.shouldLog(Log.DEBUG)) _log.debug("Stopping ntcp transport");
|
||||||
_pumper.stopPumping();
|
_pumper.stopPumping();
|
||||||
_writer.stopWriting();
|
_writer.stopWriting();
|
||||||
|
Reference in New Issue
Block a user