Skip to content

Commit

Permalink
morph: fix nil pointer dereferencing to connection
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
End-rey committed Dec 26, 2024
1 parent e75fda2 commit 1e7896e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Changelog for NeoFS Node

### Fixed
- `neofs-cli object delete` command output (#3056)
- 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)
Expand Down
4 changes: 3 additions & 1 deletion pkg/morph/client/multi.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,7 @@ func (c *Client) closeWaiter() {
case <-c.closeChan:
}
var conn = c.conn.Swap(nil)
conn.Close()
if conn != nil {
conn.Close()
}

Check warning on line 69 in pkg/morph/client/multi.go

View check run for this annotation

Codecov / codecov/patch

pkg/morph/client/multi.go#L67-L69

Added lines #L67 - L69 were not covered by tests
}
3 changes: 3 additions & 0 deletions pkg/morph/client/notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@ routeloop:
if conn == nil {
c.logger.Info("RPC connection lost, attempting reconnect")
conn = c.switchRPC()
if conn == nil {
break routeloop

Check warning on line 233 in pkg/morph/client/notifications.go

View check run for this annotation

Codecov / codecov/patch

pkg/morph/client/notifications.go#L232-L233

Added lines #L232 - L233 were not covered by tests
}
go c.restoreSubscriptions(conn, restoreCh)
}
var connLost bool
Expand Down

0 comments on commit 1e7896e

Please sign in to comment.