diff options
author | Sebastiaan van Stijn <github@gone.nl> | 2022-02-28 19:57:37 +0100 |
---|---|---|
committer | Sebastiaan van Stijn <github@gone.nl> | 2022-02-28 19:57:37 +0100 |
commit | 203fcd69976fd36b06a59210eb15d5574b897aa3 (patch) | |
tree | 4ec67ff5a585e648d86a20b3631ef72ec12b06ba /layer/migration.go | |
parent | d809ad98e32860b07269187f8bc88781dd33c67d (diff) | |
download | docker-203fcd69976fd36b06a59210eb15d5574b897aa3.tar.gz |
layers: remove layerStore.getWithoutLock()
This function was abstracting things a bit too much; the layerStore had a
exported `.Get()` which called `.getWithoutLock()`, but also a non-exported
`.get()`, which also called `.getWithoutLock()`.
While it's common to have a non-exported variant (without locking), the naming
of `.get()` could easily be confused for that variant (which it wasn't).
All locations where `.get()` was called were already handling locks for
`releaseLayer()`, so moving the actual locking inline for `.get()` makes it
more visible where locking happens.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Diffstat (limited to 'layer/migration.go')
-rw-r--r-- | layer/migration.go | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/layer/migration.go b/layer/migration.go index 80f0ff7ff4..5c8179a434 100644 --- a/layer/migration.go +++ b/layer/migration.go @@ -87,7 +87,9 @@ func (ls *layerStore) RegisterByGraphID(graphID string, parent ChainID, diffID D var err error var p *roLayer if string(parent) != "" { + ls.layerL.Lock() p = ls.get(parent) + ls.layerL.Unlock() if p == nil { return nil, ErrLayerDoesNotExist } @@ -117,7 +119,7 @@ func (ls *layerStore) RegisterByGraphID(graphID string, parent ChainID, diffID D ls.layerL.Lock() defer ls.layerL.Unlock() - if existingLayer := ls.getWithoutLock(layer.chainID); existingLayer != nil { + if existingLayer := ls.get(layer.chainID); existingLayer != nil { // Set error for cleanup, but do not return err = errors.New("layer already exists") return existingLayer.getReference(), nil |