repl.Stop() to only if running, fixes panic after js> exit followed by interrupt

This commit is contained in:
zelig 2014-06-25 18:18:22 +01:00
parent bf57e9603b
commit 6763d28a17

View File

@ -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) {