-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- **NEW** added builds for Arm64 flavours - meow hash option is not supported on Arm64 and will return 0 if called - blake2 hash option is not supported on Arm64 and will return 0 if called - `macos-arm64.zip` and `longtail-macos-arm64` artifacts are produced when creating a release - **UPDATED** Updated to longtail 0.4.0
- Loading branch information
1 parent
4469fb5
commit 6076be7
Showing
11 changed files
with
165 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package longtaillib | ||
|
||
// #cgo LDFLAGS: -L${SRCDIR}/longtail -llongtail_darwin_arm64 -lm | ||
import "C" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// +build aix darwin dragonfly freebsd js,wasm linux nacl netbsd openbsd solaris | ||
|
||
package longtailstorelib | ||
|
||
import ( | ||
"fmt" | ||
"syscall" | ||
"time" | ||
|
||
"github.com/pkg/errors" | ||
) | ||
|
||
type Lock struct { | ||
filename string | ||
fd int | ||
} | ||
|
||
func NewFileLock(filename string) *Lock { | ||
return &Lock{filename: filename} | ||
} | ||
|
||
func (l *Lock) Lock() error { | ||
const fname = "Lock.open" | ||
if err := l.open(); err != nil { | ||
return errors.Wrap(err, fname) | ||
} | ||
return syscall.Flock(l.fd, syscall.LOCK_EX) | ||
} | ||
|
||
func (l *Lock) Unlock() error { | ||
const fname = "Lock.Unlock" | ||
err := syscall.Close(l.fd) | ||
if err != nil { | ||
return errors.Wrap(err, fname) | ||
} | ||
return nil | ||
} | ||
|
||
func (l *Lock) LockWithTimeout(timeout time.Duration) error { | ||
const fname = "Lock.LockWithTimeout" | ||
err := l.open() | ||
if err != nil { | ||
return errors.Wrap(err, fname) | ||
} | ||
result := make(chan error) | ||
cancel := make(chan struct{}) | ||
go func() { | ||
err := syscall.Flock(l.fd, syscall.LOCK_EX) | ||
select { | ||
case <-cancel: | ||
// Timed out, cleanup if necessary. | ||
syscall.Flock(l.fd, syscall.LOCK_UN) | ||
syscall.Close(l.fd) | ||
case result <- err: | ||
} | ||
}() | ||
select { | ||
case err := <-result: | ||
return errors.Wrap(err, fname) | ||
case <-time.After(timeout): | ||
close(cancel) | ||
err := fmt.Errorf("Retry timed out for lock file `%s`, waited %s", l.filename, timeout.String()) | ||
return errors.Wrap(err, fname) | ||
} | ||
} | ||
|
||
func (l *Lock) open() error { | ||
const fname = "Lock.open" | ||
fd, err := syscall.Open(l.filename, syscall.O_CREAT|syscall.O_RDONLY, 0600) | ||
if err != nil { | ||
return errors.Wrap(err, fname) | ||
} | ||
l.fd = fd | ||
return nil | ||
} |