Prevent two NTCP Pumpers
This commit is contained in:
@ -285,9 +285,10 @@ public class CommSystemFacadeImpl extends CommSystemFacade {
|
|||||||
_log.warn("Halting NTCP to change address");
|
_log.warn("Halting NTCP to change address");
|
||||||
t.stopListening();
|
t.stopListening();
|
||||||
newAddr.setOptions(newProps);
|
newAddr.setOptions(newProps);
|
||||||
// Give NTCP Pumper time to stop so we don't end up with two...
|
// Wait for NTCP Pumper to stop so we don't end up with two...
|
||||||
// Need better way
|
while (t.isAlive()) {
|
||||||
try { Thread.sleep(5*1000); } catch (InterruptedException ie) {}
|
try { Thread.sleep(5*1000); } catch (InterruptedException ie) {}
|
||||||
|
}
|
||||||
t.restartListening(newAddr);
|
t.restartListening(newAddr);
|
||||||
_log.warn("Changed NTCP Address and started up, address is now " + newAddr);
|
_log.warn("Changed NTCP Address and started up, address is now " + newAddr);
|
||||||
return;
|
return;
|
||||||
|
@ -85,6 +85,13 @@ public class EventPumper implements Runnable {
|
|||||||
_selector.wakeup();
|
_selector.wakeup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Selector can take quite a while to close after calling stopPumping()
|
||||||
|
*/
|
||||||
|
public boolean isAlive() {
|
||||||
|
return _alive || (_selector != null && _selector.isOpen());
|
||||||
|
}
|
||||||
|
|
||||||
public void register(ServerSocketChannel chan) {
|
public void register(ServerSocketChannel chan) {
|
||||||
if (_log.shouldLog(Log.DEBUG)) _log.debug("Registering server socket channel");
|
if (_log.shouldLog(Log.DEBUG)) _log.debug("Registering server socket channel");
|
||||||
synchronized (_wantsRegister) { _wantsRegister.add(chan); }
|
synchronized (_wantsRegister) { _wantsRegister.add(chan); }
|
||||||
|
@ -432,6 +432,10 @@ public class NTCPTransport extends TransportImpl {
|
|||||||
return bindAddress();
|
return bindAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isAlive() {
|
||||||
|
return _pumper.isAlive();
|
||||||
|
}
|
||||||
|
|
||||||
private RouterAddress bindAddress() {
|
private RouterAddress bindAddress() {
|
||||||
if (_myAddress != null) {
|
if (_myAddress != null) {
|
||||||
try {
|
try {
|
||||||
@ -538,6 +542,10 @@ public class NTCPTransport extends TransportImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This doesn't (completely) block, caller should check isAlive()
|
||||||
|
* before calling startListening() or restartListening()
|
||||||
|
*/
|
||||||
public void stopListening() {
|
public 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();
|
||||||
|
Reference in New Issue
Block a user