aboutsummaryrefslogtreecommitdiffstats
path: root/node/errors.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2017-08-18 18:14:00 +0800
committerFelix Lange <fjl@twurst.com>2017-08-18 18:14:00 +0800
commit7e57fee3551ad5b66c985ad208613fd80c2d6b8a (patch)
treede1f4cd45dd0e727c0fba9fc84d14a324d70657b /node/errors.go
parent104375f398bdfca88183010cc3693e377ea74163 (diff)
downloaddexon-7e57fee3551ad5b66c985ad208613fd80c2d6b8a.tar.gz
dexon-7e57fee3551ad5b66c985ad208613fd80c2d6b8a.tar.zst
dexon-7e57fee3551ad5b66c985ad208613fd80c2d6b8a.zip
node: fix instance dir locking and improve error message
The lock file was ineffective because opening leveldb storage in read-only mode doesn't really take the lock. Fix it by including a dedicated flock library (which is actually split out of goleveldb).
Diffstat (limited to 'node/errors.go')
-rw-r--r--node/errors.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/node/errors.go b/node/errors.go
index bd5ddeb5d..2e0dadc4d 100644
--- a/node/errors.go
+++ b/node/errors.go
@@ -17,10 +17,28 @@
package node
import (
+ "errors"
"fmt"
"reflect"
+ "syscall"
)
+var (
+ ErrDatadirUsed = errors.New("datadir already used by another process")
+ ErrNodeStopped = errors.New("node not started")
+ ErrNodeRunning = errors.New("node already running")
+ ErrServiceUnknown = errors.New("unknown service")
+
+ datadirInUseErrnos = map[uint]bool{11: true, 32: true, 35: true}
+)
+
+func convertFileLockError(err error) error {
+ if errno, ok := err.(syscall.Errno); ok && datadirInUseErrnos[uint(errno)] {
+ return ErrDatadirUsed
+ }
+ return err
+}
+
// DuplicateServiceError is returned during Node startup if a registered service
// constructor returns a service of the same type that was already started.
type DuplicateServiceError struct {