From 381824477ec92a805dd4011d94eeddf9635a86b3 Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Thu, 2 Oct 2014 00:04:34 -0700 Subject: [PATCH] Bugfix: daemon wg sync --- cmd/ipfs/init.go | 2 +- daemon/daemon.go | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/ipfs/init.go b/cmd/ipfs/init.go index f007972ba..b868f2b91 100644 --- a/cmd/ipfs/init.go +++ b/cmd/ipfs/init.go @@ -2,9 +2,9 @@ package main import ( "encoding/base64" - "path/filepath" "errors" "os" + "path/filepath" "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/gonuts/flag" "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/commander" diff --git a/daemon/daemon.go b/daemon/daemon.go index 2e4681592..8ec84d848 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -94,7 +94,10 @@ func (dl *DaemonListener) Listen() { panic("attempting to listen on a closed daemon Listener") } + // add ourselves to workgroup. and remove ourselves when done. dl.wg.Add(1) + defer dl.wg.Done() + log.Info("daemon listening") for { conn, err := dl.list.Accept() @@ -102,7 +105,6 @@ func (dl *DaemonListener) Listen() { if !dl.closed { log.Warning("DaemonListener Accept: %v", err) } - dl.lk.Close() return } go dl.handleConnection(conn)