Skip to content

Commit

Permalink
hopefully fix a segfault with broken connections.
Browse files Browse the repository at this point in the history
  • Loading branch information
fiatjaf committed Sep 21, 2024
1 parent 7fd28f6 commit 23ddac3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ func (r *Relay) ConnectWithTLS(ctx context.Context, tlsConfig *tls.Config) error

// stop the ticker
ticker.Stop()

// nil the connection
r.Connection = nil

// close all subscriptions
r.Subscriptions.Range(func(_ string, sub *Subscription) bool {
go sub.Unsub()
Expand Down Expand Up @@ -520,7 +524,6 @@ func (r *Relay) Close() error {
}

err := r.Connection.Close()
r.Connection = nil
if err != nil {
return err
}
Expand Down

0 comments on commit 23ddac3

Please sign in to comment.