summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHubert Hirtz <hubert@hirtzfr.eu>2020-08-19 15:17:53 +0200
committerHubert Hirtz <hubert@hirtzfr.eu>2020-08-19 21:56:39 +0200
commit4d806b75e2a903a725069b23df555714122974e6 (patch)
tree33d0baa546bd9c5ec95819d8ce798ed25bd9498e
parentui: Show self /msg and /r even if echo-message is off (diff)
Properly close everything in case of error
-rw-r--r--app.go3
-rw-r--r--irc/states.go6
2 files changed, 9 insertions, 0 deletions
diff --git a/app.go b/app.go
index 6025595..0383f09 100644
--- a/app.go
+++ b/app.go
@@ -36,6 +36,7 @@ func NewApp(cfg Config) (app *App, err error) {
app.win.AddLine(ui.Home, ui.NewLineNow("--", fmt.Sprintf("Connecting to %s...", cfg.Addr)))
conn, err = tls.Dial("tcp", cfg.Addr, nil)
if err != nil {
+ app.win.Close()
return
}
@@ -51,6 +52,8 @@ func NewApp(cfg Config) (app *App, err error) {
Debug: cfg.Debug,
})
if err != nil {
+ app.win.Close()
+ _ = conn.Close()
return
}
diff --git a/irc/states.go b/irc/states.go
index d826d7d..762ed71 100644
--- a/irc/states.go
+++ b/irc/states.go
@@ -214,8 +214,14 @@ func (s *Session) Running() bool {
}
func (s *Session) Stop() {
+ if !s.Running() {
+ return
+ }
s.running.Store(false)
_ = s.conn.Close()
+ close(s.acts)
+ close(s.evts)
+ close(s.msgs)
}
func (s *Session) Poll() (events <-chan Event) {