Check disconnected flag on each operation 31/102631/1
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 18 Oct 2022 14:44:39 +0000 (16:44 +0200)
committerRobert Varga <nite@hq.sk>
Tue, 18 Oct 2022 16:07:02 +0000 (16:07 +0000)
commitafef223672144f174d4da6ef079ee19ad6ebf568
treea71baa278495eea4095af952ab1209fad8b90247
parent7e9fc20c4c5f4c5e52e40adaaea3006e857d6249
Check disconnected flag on each operation

We are performing a staggered setup during which we may encounter an
asynchronous disconnect. We have an atomic flag guarding this, which is
always flipped before disconnect enters critical region.

Check the flag at each synchronized connect stage and abort connection
if it is observed as flipped -- ensuring we cannot accidentally signal
channel activation after the channel has been close()d.

Also ditch the AtomicBoolean and instead use a simple VarHandle, saving
a few bytes of overhead.

JIRA: NETCONF-905
Change-Id: I857b1768b083c13ac5060a803a9ba6d4008c5e4b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit bdc0153931463070df6d03c75357e08f65bb9783)
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/client/AsyncSshHandler.java