repl.Stop() to only if running, fixes panic after js> exit followed by interrupt
This commit is contained in:
parent
bf57e9603b
commit
6763d28a17
|
@ -23,6 +23,8 @@ type JSRepl struct {
|
||||||
prompt string
|
prompt string
|
||||||
|
|
||||||
history *os.File
|
history *os.File
|
||||||
|
|
||||||
|
running bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewJSRepl(ethereum *eth.Ethereum) *JSRepl {
|
func NewJSRepl(ethereum *eth.Ethereum) *JSRepl {
|
||||||
|
@ -35,26 +37,32 @@ func NewJSRepl(ethereum *eth.Ethereum) *JSRepl {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *JSRepl) Start() {
|
func (self *JSRepl) Start() {
|
||||||
logger.Infoln("init JS Console")
|
if !self.running {
|
||||||
reader := bufio.NewReader(self.history)
|
self.running = true
|
||||||
for {
|
logger.Infoln("init JS Console")
|
||||||
line, err := reader.ReadString('\n')
|
reader := bufio.NewReader(self.history)
|
||||||
if err != nil && err == io.EOF {
|
for {
|
||||||
break
|
line, err := reader.ReadString('\n')
|
||||||
} else if err != nil {
|
if err != nil && err == io.EOF {
|
||||||
fmt.Println("error reading history", err)
|
break
|
||||||
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() {
|
func (self *JSRepl) Stop() {
|
||||||
self.re.Stop()
|
if self.running {
|
||||||
logger.Infoln("exit JS Console")
|
self.running = false
|
||||||
self.history.Close()
|
self.re.Stop()
|
||||||
|
logger.Infoln("exit JS Console")
|
||||||
|
self.history.Close()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *JSRepl) parseInput(code string) {
|
func (self *JSRepl) parseInput(code string) {
|
||||||
|
|
Loading…
Reference in New Issue