cmd/utils, rpc/comms: stop XEth when IPC connection ends

There are a bunch of changes required to make this work:

- in miner: allow unregistering agents, fix RemoteAgent.Stop
- in eth/filters: make FilterSystem.Stop not crash
- in rpc/comms: move listen loop to platform-independent code

Fixes #1930. I ran the shell loop there for a few minutes and didn't see
any changes in the memory profile.
This commit is contained in:
Felix Lange
2015-10-29 13:28:00 +01:00
parent 56f8699a6c
commit fbdb44dcc1
9 changed files with 129 additions and 159 deletions

View File

@ -113,19 +113,15 @@ func New(ethereum *eth.Ethereum, frontend Frontend) *XEth {
if frontend == nil {
xeth.frontend = dummyFrontend{}
}
state, err := xeth.backend.BlockChain().State()
if err != nil {
return nil
}
state, _ := xeth.backend.BlockChain().State()
xeth.state = NewState(xeth, state)
go xeth.start()
return xeth
}
func (self *XEth) start() {
timer := time.NewTicker(2 * time.Second)
defer timer.Stop()
done:
for {
select {
@ -171,8 +167,12 @@ done:
}
}
func (self *XEth) stop() {
// Stop releases any resources associated with self.
// It may not be called more than once.
func (self *XEth) Stop() {
close(self.quit)
self.filterManager.Stop()
self.backend.Miner().Unregister(self.agent)
}
func cAddress(a []string) []common.Address {