bolt: strict 10 second timeout for opening databases
This commit is contained in:
parent
f0f642b6b0
commit
b5149c4efa
5
main.go
5
main.go
@ -6,6 +6,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"os"
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/boltdb/bolt"
|
"github.com/boltdb/bolt"
|
||||||
)
|
)
|
||||||
@ -26,7 +27,9 @@ func GetMagic() int64 {
|
|||||||
|
|
||||||
//export Bolt_Open
|
//export Bolt_Open
|
||||||
func Bolt_Open(path string) (ObjectReference, *C.char, int) {
|
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 {
|
if err != nil {
|
||||||
errMsg := err.Error()
|
errMsg := err.Error()
|
||||||
return 0, C.CString(errMsg), len(errMsg)
|
return 0, C.CString(errMsg), len(errMsg)
|
||||||
|
Loading…
Reference in New Issue
Block a user