mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 19:17:28 +01:00
18 lines
363 B
Go
18 lines
363 B
Go
//go:build windows
|
|
|
|
package hostlimit
|
|
|
|
import (
|
|
"errors"
|
|
"golang.org/x/sys/windows"
|
|
"os"
|
|
)
|
|
|
|
func tryLock(f *os.File) error {
|
|
err := windows.LockFileEx(windows.Handle(f.Fd()), windows.LOCKFILE_EXCLUSIVE_LOCK|windows.LOCKFILE_FAIL_IMMEDIATELY, 0, 1, 0, &windows.Overlapped{})
|
|
if errors.Is(err, windows.ERROR_LOCK_VIOLATION) {
|
|
return ErrBusy
|
|
}
|
|
return err
|
|
}
|