From e643525d5cc0776ac36b2ac20362299cb7112f45 Mon Sep 17 00:00:00 2001 From: Gokcehan Date: Tue, 22 Nov 2016 20:42:37 +0300 Subject: [PATCH] use a buffered channel for quitting --- app.go | 5 ++--- eval.go | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app.go b/app.go index 7cf8e53..5a62540 100644 --- a/app.go +++ b/app.go @@ -22,7 +22,7 @@ type App struct { func newApp() *App { ui := newUI() nav := newNav(ui.wins[0].h) - quit := make(chan bool) + quit := make(chan bool, 1) return &App{ ui: ui, @@ -190,8 +190,7 @@ func (app *App) readExpr() chan MultiExpr { // This is the main event loop of the application. There are two channels to // read expressions from client and server. Reading and evaluation are done on -// different goroutines except for prompting commands (e.g. "read"). Quitting -// commands should create separate goroutines to prevent deadlock here. +// different goroutines except for prompting commands (e.g. "read"). func (app *App) handleInp() { clientChan := app.readExpr() diff --git a/eval.go b/eval.go index 9ce5210..599fd6f 100644 --- a/eval.go +++ b/eval.go @@ -215,7 +215,7 @@ func (e *CallExpr) eval(app *App, args []string) { log.Printf("writing selection file: %s", err) } - go func() { app.quit <- true }() + app.quit <- true return } @@ -224,7 +224,7 @@ func (e *CallExpr) eval(app *App, args []string) { cmd.eval(app, e.args) } case "quit": - go func() { app.quit <- true }() + app.quit <- true case "bot": app.nav.bot() app.ui.loadFile(app.nav)