1. Add synchronized to BGPPeer#releaseConnection to avoid race condition
2. Add check to BGPSessionImpl#closeWithoutMessage so that it's body does not
get executed twice, even if it does get called twice during session cleanup
Change-Id: I78d89de2c9c0fa8968bbb6a019d568a539a8c5f7
Signed-off-by: Ajay <ajayl.bro@gmail.com>
}
}
- private synchronized void cleanup() {
+ private void cleanup() {
// FIXME: BUG-196: support graceful
this.adjRibOutListenerSet.values().forEach(AdjRibOutListener::close);
this.adjRibOutListenerSet.clear();
}
@Override
- public void releaseConnection() {
+ @GuardedBy("this")
+ public synchronized void releaseConnection() {
if (this.rpcRegistration != null) {
this.rpcRegistration.close();
}
}
}
- @GuardedBy("this")
private void dropConnection() {
if (this.runtimeReg != null) {
this.runtimeReg.close();
public synchronized void close() {
if (this.state != State.IDLE) {
this.writeAndFlush(new NotifyBuilder().setErrorCode(BGPError.CEASE.getCode()).setErrorSubcode(BGPError.CEASE.getSubcode()).build());
+ this.closeWithoutMessage();
}
- this.closeWithoutMessage();
}
/**
}
private synchronized void closeWithoutMessage() {
+ if (this.state == State.IDLE) {
+ return;
+ }
LOG.info("Closing session: {}", this);
removePeerSession();
this.channel.close().addListener(new ChannelFutureListener() {