fix netconf automatic reconnection issue (check both isClosed and isClosing)

Change-Id: I3c52ccb5a34893c4b0e952faa1a183d4daa32707
diff --git a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfSessionMinaImpl.java b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfSessionMinaImpl.java
index e39df71..96c79ed 100644
--- a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfSessionMinaImpl.java
+++ b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfSessionMinaImpl.java
@@ -397,15 +397,15 @@
     @Override
     public void checkAndReestablish() throws NetconfException {
         try {
-            if (client.isClosed()) {
+            if (client.isClosed() || client.isClosing()) {
                 log.debug("Trying to restart the whole SSH connection with {}", deviceInfo.getDeviceId());
                 cleanUp();
                 startConnection();
-            } else if (session.isClosed()) {
+            } else if (session.isClosed() || session.isClosing()) {
                 log.debug("Trying to restart the session with {}", session, deviceInfo.getDeviceId());
                 cleanUp();
                 startSession();
-            } else if (channel.isClosed()) {
+            } else if (channel.isClosed() || channel.isClosing()) {
                 log.debug("Trying to reopen the channel with {}", deviceInfo.getDeviceId());
                 cleanUp();
                 openChannel();