Skip to content

daemon/cluster: add a missing Unlock#40594

Merged
cpuguy83 merged 1 commit intomoby:masterfrom
sfzhu93:Mis_Unlock
Feb 28, 2020
Merged

daemon/cluster: add a missing Unlock#40594
cpuguy83 merged 1 commit intomoby:masterfrom
sfzhu93:Mis_Unlock

Conversation

@sfzhu93
Copy link
Copy Markdown

@sfzhu93 sfzhu93 commented Feb 27, 2020

- What I did
The following code has a missing Unlock:

// Take c.mu temporarily to wait for presently running
// API handlers to finish before shutting down the node.
c.mu.Lock()
if !c.nr.nodeState.IsManager() {
return "", errSwarmNotManager
}
c.mu.Unlock()

This PR adds an Unlock before return with error.

- How to verify it
We checked other places where this RWMutex is used, and Lock is always followed with Unlock in control-flow-graph, except in this place.

- Description for the changelog
Adds a missing Unlock before return with error.

- A picture of a cute animal (not mandatory but encouraged)
🐷

Signed-off-by: Ziheng Liu <lzhfromustc@gmail.com>
Copy link
Copy Markdown
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Member

@cpuguy83 cpuguy83 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants