1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #23939 from vdemeester/rename-same-no-lock

No need for container.Lock if rename same name
This commit is contained in:
Vincent Demeester 2016-06-25 14:56:20 +02:00 committed by GitHub
commit 9ed0feece8

View file

@ -33,13 +33,13 @@ func (daemon *Daemon) ContainerRename(oldName, newName string) error {
oldName = container.Name
oldIsAnonymousEndpoint := container.NetworkSettings.IsAnonymousEndpoint
container.Lock()
defer container.Unlock()
if oldName == newName {
return fmt.Errorf("Renaming a container with the same name as its current name")
}
container.Lock()
defer container.Unlock()
if newName, err = daemon.reserveName(container.ID, newName); err != nil {
return fmt.Errorf("Error when allocating new name: %v", err)
}