Skip to content

Commit

Permalink
journal: only destroy the connection if it is set
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
nixpanic committed Oct 14, 2024
1 parent e154eae commit 15b14a2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion internal/journal/volumegroupjournal.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,10 @@ func (vgc *VolumeGroupJournalConfig) Connect(

// Destroy frees any resources and invalidates the journal connection.
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
Expand Down

0 comments on commit 15b14a2

Please sign in to comment.