summaryrefslogtreecommitdiff
path: root/vendor/github.com/ncruces/go-sqlite3/vfs/os_linux.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/ncruces/go-sqlite3/vfs/os_linux.go')
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/vfs/os_linux.go46
1 files changed, 37 insertions, 9 deletions
diff --git a/vendor/github.com/ncruces/go-sqlite3/vfs/os_linux.go b/vendor/github.com/ncruces/go-sqlite3/vfs/os_linux.go
index 6199c7b00..d112c5a99 100644
--- a/vendor/github.com/ncruces/go-sqlite3/vfs/os_linux.go
+++ b/vendor/github.com/ncruces/go-sqlite3/vfs/os_linux.go
@@ -3,6 +3,7 @@
package vfs
import (
+ "io"
"os"
"time"
@@ -11,14 +12,36 @@ import (
func osSync(file *os.File, _ /*fullsync*/, _ /*dataonly*/ bool) error {
// SQLite trusts Linux's fdatasync for all fsync's.
- return unix.Fdatasync(int(file.Fd()))
+ for {
+ err := unix.Fdatasync(int(file.Fd()))
+ if err != unix.EINTR {
+ return err
+ }
+ }
}
func osAllocate(file *os.File, size int64) error {
if size == 0 {
return nil
}
- return unix.Fallocate(int(file.Fd()), 0, 0, size)
+ for {
+ err := unix.Fallocate(int(file.Fd()), 0, 0, size)
+ if err == unix.EOPNOTSUPP {
+ break
+ }
+ if err != unix.EINTR {
+ return err
+ }
+ }
+ off, err := file.Seek(0, io.SeekEnd)
+ if err != nil {
+ return err
+ }
+ if size <= off {
+ return nil
+ }
+ return file.Truncate(size)
+
}
func osReadLock(file *os.File, start, len int64, timeout time.Duration) _ErrorCode {
@@ -37,22 +60,27 @@ func osLock(file *os.File, typ int16, start, len int64, timeout time.Duration, d
}
var err error
switch {
- case timeout < 0:
- err = unix.FcntlFlock(file.Fd(), unix.F_OFD_SETLKW, &lock)
default:
err = unix.FcntlFlock(file.Fd(), unix.F_OFD_SETLK, &lock)
+ case timeout < 0:
+ err = unix.FcntlFlock(file.Fd(), unix.F_OFD_SETLKW, &lock)
}
return osLockErrorCode(err, def)
}
func osUnlock(file *os.File, start, len int64) _ErrorCode {
- err := unix.FcntlFlock(file.Fd(), unix.F_OFD_SETLK, &unix.Flock_t{
+ lock := unix.Flock_t{
Type: unix.F_UNLCK,
Start: start,
Len: len,
- })
- if err != nil {
- return _IOERR_UNLOCK
}
- return _OK
+ for {
+ err := unix.FcntlFlock(file.Fd(), unix.F_OFD_SETLK, &lock)
+ if err == nil {
+ return _OK
+ }
+ if err != unix.EINTR {
+ return _IOERR_UNLOCK
+ }
+ }
}