From 7e1ec8d2bd6d1aa77f824a1a4d717a7aa4cc3459 Mon Sep 17 00:00:00 2001 From: Vincent Demeester Date: Fri, 24 Jun 2016 19:55:48 +0200 Subject: [PATCH] No need for container.Lock if rename same name During the renaming of a container, no need to call `container.Lock()` if `oldName == newName`. This is a follow-up from #23360 (commit 88d1ee6c112d980a63c625389524047fea32e6d9) Signed-off-by: Vincent Demeester --- daemon/rename.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/daemon/rename.go b/daemon/rename.go index f921accbc9..e92dfda861 100644 --- a/daemon/rename.go +++ b/daemon/rename.go @@ -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) }