From 8170f96dedb983c391d26378726d7fd6921ff959 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Wed, 29 Oct 2014 03:00:29 +0100 Subject: [PATCH 1/2] javascript: remove unused quit channel This fixes the hang in JSRE.Stop. --- javascript/javascript_runtime.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/javascript/javascript_runtime.go b/javascript/javascript_runtime.go index 704635d97..6c5a87338 100644 --- a/javascript/javascript_runtime.go +++ b/javascript/javascript_runtime.go @@ -25,8 +25,7 @@ type JSRE struct { Vm *otto.Otto pipe *ethpipe.JSPipe - events event.Subscription - quitChan chan bool + events event.Subscription objectCb map[string][]otto.Value } @@ -51,7 +50,6 @@ func NewJSRE(ethereum *eth.Ethereum) *JSRE { otto.New(), ethpipe.NewJSPipe(ethereum), nil, - make(chan bool), make(map[string][]otto.Value), } @@ -104,10 +102,6 @@ func (self *JSRE) Require(file string) error { func (self *JSRE) Stop() { self.events.Unsubscribe() - // Kill the main loop - self.quitChan <- true - - close(self.quitChan) jsrelogger.Infoln("stopped") } From e252dbf989f8a8e08e3edcaf075febee315e53fd Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Wed, 29 Oct 2014 03:01:20 +0100 Subject: [PATCH 2/2] eth: stop eventMux first This fixes the hang in Ethereum.Stop. --- ethereum.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ethereum.go b/ethereum.go index c2d209597..a389c663d 100644 --- a/ethereum.go +++ b/ethereum.go @@ -490,6 +490,9 @@ func (s *Ethereum) peerHandler(listener net.Listener) { } func (s *Ethereum) Stop() { + // Stop eventMux first, it will close all subscriptions. + s.eventMux.Stop() + // Close the database defer s.db.Close() @@ -514,7 +517,6 @@ func (s *Ethereum) Stop() { } s.txPool.Stop() s.stateManager.Stop() - s.eventMux.Stop() s.blockPool.Stop() ethlogger.Infoln("Server stopped")