Browse Source

fix a dead lock

pull/279/head
tnextday 10 years ago
parent
commit
b757e6aeca
  1. 13
      weed/topology/data_node.go
  2. 6
      weed/topology/node.go

13
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 {

6
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)
}

Loading…
Cancel
Save