From b5149c4efa37ecbdcfb0790eedf655005c8d0c7d Mon Sep 17 00:00:00 2001 From: mappu Date: Sun, 21 May 2017 18:05:20 +1200 Subject: [PATCH] bolt: strict 10 second timeout for opening databases --- main.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 00df9dc..c5e4a93 100644 --- a/main.go +++ b/main.go @@ -6,6 +6,7 @@ import ( "encoding/json" "errors" "os" + "time" "github.com/boltdb/bolt" ) @@ -26,7 +27,9 @@ func GetMagic() int64 { //export Bolt_Open func Bolt_Open(path string) (ObjectReference, *C.char, int) { - ptrDB, err := bolt.Open(path, os.FileMode(0644), bolt.DefaultOptions) + opts := *bolt.DefaultOptions + opts.Timeout = 10 * time.Second + ptrDB, err := bolt.Open(path, os.FileMode(0644), &opts) if err != nil { errMsg := err.Error() return 0, C.CString(errMsg), len(errMsg)