Replace lockfile with reference lock
Updates content service to handle lock errors and return them to the client. The client remote handler has been updated to retry when a resource is locked until the resource is unlocked or the expected resource exists. Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
@@ -5,8 +5,6 @@ import (
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/nightlyone/lockfile"
|
||||
"github.com/opencontainers/go-digest"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
@@ -15,9 +13,8 @@ import (
|
||||
type writer struct {
|
||||
s *store
|
||||
fp *os.File // opened data file
|
||||
lock lockfile.Lockfile
|
||||
path string // path to writer dir
|
||||
ref string // ref key
|
||||
path string // path to writer dir
|
||||
ref string // ref key
|
||||
offset int64
|
||||
total int64
|
||||
digester digest.Digester
|
||||
@@ -107,8 +104,9 @@ func (w *writer) Commit(size int64, expected digest.Digest) error {
|
||||
return err
|
||||
}
|
||||
|
||||
unlock(w.lock)
|
||||
unlock(w.ref)
|
||||
w.fp = nil
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -122,9 +120,7 @@ func (w *writer) Commit(size int64, expected digest.Digest) error {
|
||||
// To abandon a transaction completely, first call close then `Store.Remove` to
|
||||
// clean up the associated resources.
|
||||
func (cw *writer) Close() (err error) {
|
||||
if err := unlock(cw.lock); err != nil {
|
||||
log.L.Debug("unlock failed: %v", err)
|
||||
}
|
||||
unlock(cw.ref)
|
||||
|
||||
if cw.fp != nil {
|
||||
cw.fp.Sync()
|
||||
|
||||
Reference in New Issue
Block a user