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:
@ -23,8 +23,6 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/ethereum/go-ethereum/logger"
|
||||
"github.com/ethereum/go-ethereum/logger/glog"
|
||||
"github.com/ethereum/go-ethereum/rpc/codec"
|
||||
"github.com/ethereum/go-ethereum/rpc/shared"
|
||||
"github.com/ethereum/go-ethereum/rpc/useragent"
|
||||
@ -69,44 +67,16 @@ func (self *ipcClient) reconnect() error {
|
||||
return err
|
||||
}
|
||||
|
||||
func startIpc(cfg IpcConfig, codec codec.Codec, initializer func(conn net.Conn) (shared.EthereumApi, error)) error {
|
||||
func ipcListen(cfg IpcConfig) (net.Listener, error) {
|
||||
// Ensure the IPC path exists and remove any previous leftover
|
||||
if err := os.MkdirAll(filepath.Dir(cfg.Endpoint), 0751); err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
os.Remove(cfg.Endpoint)
|
||||
|
||||
l, err := net.ListenUnix("unix", &net.UnixAddr{Name: cfg.Endpoint, Net: "unix"})
|
||||
l, err := net.Listen("unix", cfg.Endpoint)
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
os.Chmod(cfg.Endpoint, 0600)
|
||||
|
||||
go func() {
|
||||
for {
|
||||
conn, err := l.AcceptUnix()
|
||||
if err != nil {
|
||||
glog.V(logger.Error).Infof("Error accepting ipc connection - %v\n", err)
|
||||
continue
|
||||
}
|
||||
|
||||
id := newIpcConnId()
|
||||
glog.V(logger.Debug).Infof("New IPC connection with id %06d started\n", id)
|
||||
|
||||
api, err := initializer(conn)
|
||||
if err != nil {
|
||||
glog.V(logger.Error).Infof("Unable to initialize IPC connection - %v\n", err)
|
||||
conn.Close()
|
||||
continue
|
||||
}
|
||||
|
||||
go handle(id, conn, api, codec)
|
||||
}
|
||||
|
||||
os.Remove(cfg.Endpoint)
|
||||
}()
|
||||
|
||||
glog.V(logger.Info).Infof("IPC service started (%s)\n", cfg.Endpoint)
|
||||
|
||||
return nil
|
||||
return l, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user