journal: only destroy the connection if it is set

Prevent re-use of a destroyed connection by setting it to `nil`. This
way it is also safe to call `Destroy()` multiple times without causing a
panic.

Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
Niels de Vos 2024-10-01 09:29:27 +02:00 committed by mergify[bot]
parent e154eae732
commit 6df173dbf3

View File

@ -143,7 +143,10 @@ func (vgc *VolumeGroupJournalConfig) Connect(
// Destroy frees any resources and invalidates the journal connection. // Destroy frees any resources and invalidates the journal connection.
func (vgjc *volumeGroupJournalConnection) Destroy() { func (vgjc *volumeGroupJournalConnection) Destroy() {
vgjc.connection.Destroy() if vgjc.connection != nil {
vgjc.connection.Destroy()
vgjc.connection = nil
}
} }
// VolumeGroupData contains the GroupUUID and VolumeGroupAttributes for a // VolumeGroupData contains the GroupUUID and VolumeGroupAttributes for a