From b757e6aecab82634cdd777c05edb9ba153ab2565 Mon Sep 17 00:00:00 2001 From: tnextday Date: Mon, 4 Apr 2016 23:34:44 +0800 Subject: [PATCH] fix a dead lock --- weed/topology/data_node.go | 13 ++++++++++--- weed/topology/node.go | 6 ++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/weed/topology/data_node.go b/weed/topology/data_node.go index e332a10be..4798a3c38 100644 --- a/weed/topology/data_node.go +++ b/weed/topology/data_node.go @@ -4,10 +4,11 @@ import ( "fmt" "strconv" - "github.com/chrislusf/seaweedfs/weed/glog" - "github.com/chrislusf/seaweedfs/weed/storage" "net" "time" + + "github.com/chrislusf/seaweedfs/weed/glog" + "github.com/chrislusf/seaweedfs/weed/storage" ) type DataNode struct { @@ -32,7 +33,13 @@ func NewDataNode(id string) *DataNode { func (dn *DataNode) String() string { dn.mutex.RLock() defer dn.mutex.RUnlock() - return fmt.Sprintf("Node:%s, volumes:%v, Ip:%s, Port:%d, PublicUrl:%s, Dead:%v", dn.NodeImpl.String(), dn.volumes, dn.Ip, dn.Port, dn.PublicUrl, dn.dead) + return fmt.Sprintf("Node:%s, volumes:%v, Ip:%s, Port:%d, PublicUrl:%s, Dead:%v", + dn.NodeImpl.String(), + dn.volumes, + dn.Ip, + dn.Port, + dn.PublicUrl, + dn.dead) } func (dn *DataNode) LastSeen() int64 { diff --git a/weed/topology/node.go b/weed/topology/node.go index c3e21d3dc..f8de1a28a 100644 --- a/weed/topology/node.go +++ b/weed/topology/node.go @@ -132,10 +132,8 @@ func (n *NodeImpl) IsDataCenter() bool { return n.nodeType == "DataCenter" } func (n *NodeImpl) String() string { - n.mutex.RLock() - defer n.mutex.RUnlock() - if n.parent != nil { - return n.parent.String() + ":" + string(n.id) + if n.Parent() != nil { + return n.Parent().String() + ":" + string(n.id) } return string(n.id) }