From 874d61270e92b255b256b7397853b1a41668613b 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 f007972bae5..b868f2b91dc 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 8180131bad0..76dfa06a060 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)