Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Misleading comment about thread safety? #8

@mheffner

Description

@mheffner

In updateServerList there is this comment:

// updateServerList is not thread safe and should not be called without holding lock on clusterConfigMU

However, when the method is called here:

c.updateServerList(clusterConfig)

I don't see that it is called with any mutex held. I only see clusterConfigMU ever held with a read-lock.

However, I believe there isn't actually a thread safety concern here. The prevClusterConfig appears to only be read/updated from readConfigAndUpdateServerList which is never called concurrently in the current code. The SetServers call on the ServerList is protected by a mutex so that is already protected. From what I can tell, the clusterConfigMU lock and thread safety comments could likely be removed to avoid confusion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions