aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzelig <viktor.tron@gmail.com>2014-06-26 01:18:22 +0800
committerzelig <viktor.tron@gmail.com>2014-06-26 01:18:22 +0800
commit6763d28a170b4e91c78532feed68805fe88c41dd (patch)
treed16f2e19976d85a5db82370a18c186df63c43c00
parentbf57e9603b9ef2c96e8e6d7c3d22ea674392d56b (diff)
downloaddexon-6763d28a170b4e91c78532feed68805fe88c41dd.tar
dexon-6763d28a170b4e91c78532feed68805fe88c41dd.tar.gz
dexon-6763d28a170b4e91c78532feed68805fe88c41dd.tar.bz2
dexon-6763d28a170b4e91c78532feed68805fe88c41dd.tar.lz
dexon-6763d28a170b4e91c78532feed68805fe88c41dd.tar.xz
dexon-6763d28a170b4e91c78532feed68805fe88c41dd.tar.zst
dexon-6763d28a170b4e91c78532feed68805fe88c41dd.zip
repl.Stop() to only if running, fixes panic after js> exit followed by interrupt
-rw-r--r--ethereum/repl.go38
1 files changed, 23 insertions, 15 deletions
diff --git a/ethereum/repl.go b/ethereum/repl.go
index c162c78b0..34380a06f 100644
--- a/ethereum/repl.go
+++ b/ethereum/repl.go
@@ -23,6 +23,8 @@ type JSRepl struct {
prompt string
history *os.File
+
+ running bool
}
func NewJSRepl(ethereum *eth.Ethereum) *JSRepl {
@@ -35,26 +37,32 @@ func NewJSRepl(ethereum *eth.Ethereum) *JSRepl {
}
func (self *JSRepl) Start() {
- logger.Infoln("init JS Console")
- reader := bufio.NewReader(self.history)
- for {
- line, err := reader.ReadString('\n')
- if err != nil && err == io.EOF {
- break
- } else if err != nil {
- fmt.Println("error reading history", err)
- break
+ if !self.running {
+ self.running = true
+ logger.Infoln("init JS Console")
+ reader := bufio.NewReader(self.history)
+ for {
+ line, err := reader.ReadString('\n')
+ if err != nil && err == io.EOF {
+ break
+ } else if err != nil {
+ fmt.Println("error reading history", err)
+ break
+ }
+
+ addHistory(line[:len(line)-1])
}
-
- addHistory(line[:len(line)-1])
+ self.read()
}
- self.read()
}
func (self *JSRepl) Stop() {
- self.re.Stop()
- logger.Infoln("exit JS Console")
- self.history.Close()
+ if self.running {
+ self.running = false
+ self.re.Stop()
+ logger.Infoln("exit JS Console")
+ self.history.Close()
+ }
}
func (self *JSRepl) parseInput(code string) {