avoid dead lock
This commit is contained in:
@@ -46,7 +46,7 @@ func (dn *DataNode) getOrCreateDisk(diskType string) *Disk {
|
|||||||
c, found := dn.children[NodeId(diskType)]
|
c, found := dn.children[NodeId(diskType)]
|
||||||
if !found {
|
if !found {
|
||||||
c = NewDisk(diskType)
|
c = NewDisk(diskType)
|
||||||
dn.LinkChildNode(c)
|
dn.doLinkChildNode(c)
|
||||||
}
|
}
|
||||||
disk := c.(*Disk)
|
disk := c.(*Disk)
|
||||||
return disk
|
return disk
|
||||||
|
|||||||
@@ -210,6 +210,10 @@ func (n *NodeImpl) GetMaxVolumeId() needle.VolumeId {
|
|||||||
func (n *NodeImpl) LinkChildNode(node Node) {
|
func (n *NodeImpl) LinkChildNode(node Node) {
|
||||||
n.Lock()
|
n.Lock()
|
||||||
defer n.Unlock()
|
defer n.Unlock()
|
||||||
|
n.doLinkChildNode(node)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *NodeImpl) doLinkChildNode(node Node) {
|
||||||
if n.children[node.Id()] == nil {
|
if n.children[node.Id()] == nil {
|
||||||
n.children[node.Id()] = node
|
n.children[node.Id()] = node
|
||||||
n.UpAdjustDiskUsageDelta(node.GetDiskUsages())
|
n.UpAdjustDiskUsageDelta(node.GetDiskUsages())
|
||||||
|
|||||||
Reference in New Issue
Block a user