From 48d09ab4cb817c5c198390a59297a787e7645437 Mon Sep 17 00:00:00 2001 From: Andrey Butusov Date: Wed, 25 Dec 2024 10:35:38 +0300 Subject: [PATCH] morph: fix nil pointer dereferencing to connection When the RPC connection is lost and a recovery attempt occurs, the variable `conn` responsible for the connection may be nil and therefore additional verification is needed. Closes #3061. Signed-off-by: Andrey Butusov --- CHANGELOG.md | 1 + pkg/morph/client/multi.go | 4 +++- pkg/morph/client/notifications.go | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae5c718ade..f6c63fc7f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ Changelog for NeoFS Node ### Fixed - `neofs-cli object delete` command output (#3056) - Make the error message more clearer when validating IR configuration (#3072) +- Panic during shutdown if N3 client connection is lost (#3073) ### Changed - Number of cuncurrenly handled notifications from the chain was increased from 10 to 300 for IR (#3068) diff --git a/pkg/morph/client/multi.go b/pkg/morph/client/multi.go index 1de456ef63..476a2d8edb 100644 --- a/pkg/morph/client/multi.go +++ b/pkg/morph/client/multi.go @@ -64,5 +64,7 @@ func (c *Client) closeWaiter() { case <-c.closeChan: } var conn = c.conn.Swap(nil) - conn.Close() + if conn != nil { + conn.Close() + } } diff --git a/pkg/morph/client/notifications.go b/pkg/morph/client/notifications.go index e370444b30..4e8f326487 100644 --- a/pkg/morph/client/notifications.go +++ b/pkg/morph/client/notifications.go @@ -229,6 +229,9 @@ routeloop: if conn == nil { c.logger.Info("RPC connection lost, attempting reconnect") conn = c.switchRPC() + if conn == nil { + break routeloop + } go c.restoreSubscriptions(conn, restoreCh) } var connLost bool