hopefully fix a segfault with broken connections.

This commit is contained in:
fiatjaf 2024-09-20 22:59:31 -03:00
parent 7fd28f6db0
commit 23ddac33dd

View File

@ -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()
@ -520,7 +524,6 @@ func (r *Relay) Close() error {
}
err := r.Connection.Close()
r.Connection = nil
if err != nil {
return err
}