删掉了调试用的代码。
This commit is contained in:
parent
8faca5dd52
commit
731d320fa2
|
|
@ -8,10 +8,8 @@ import (
|
|||
"sync"
|
||||
)
|
||||
|
||||
var mux sync.Mutex
|
||||
|
||||
type TunnelStatusManager struct {
|
||||
// mux sync.Mutex
|
||||
mux sync.Mutex
|
||||
tunnelList *list.List
|
||||
regChan chan interface{}
|
||||
unregChan chan interface{}
|
||||
|
|
@ -35,74 +33,23 @@ func (this *TunnelStatusManager) GetUnregChan() chan interface{} {
|
|||
}
|
||||
|
||||
func (this *TunnelStatusManager) register(t interface{}) {
|
||||
// this.mux.Lock()
|
||||
// defer this.mux.Unlock()
|
||||
mux.Lock()
|
||||
defer mux.Unlock()
|
||||
this.mux.Lock()
|
||||
defer this.mux.Unlock()
|
||||
this.tunnelList.PushBack(t)
|
||||
|
||||
l := this.tunnelList
|
||||
// c := 0
|
||||
// for e := l.Front(); e != nil; e = e.Next() {
|
||||
// c++
|
||||
// if c > l.Len() {
|
||||
// log.Error("out of bound of list")
|
||||
// }
|
||||
// if e.Value == nil {
|
||||
// log.Debug("a nil len of list %d c %d", l.Len(), c)
|
||||
// back := l.Back()
|
||||
// if back == nil {
|
||||
// log.Debug("back is nill")
|
||||
// }
|
||||
// }
|
||||
|
||||
// }
|
||||
m := t.(*model.Tunnel)
|
||||
log.Info("tunnel %s registerd len %d", m.GetID(), l.Len())
|
||||
|
||||
}
|
||||
|
||||
func (this *TunnelStatusManager) unregister(t interface{}) {
|
||||
// this.mux.Lock()
|
||||
// defer this.mux.Unlock()
|
||||
mux.Lock()
|
||||
defer mux.Unlock()
|
||||
|
||||
this.mux.Lock()
|
||||
defer this.mux.Unlock()
|
||||
l := this.tunnelList
|
||||
log.Debug("%d tunnels before remove.", this.tunnelList.Len())
|
||||
// n := 0
|
||||
nl := new(list.List)
|
||||
// tn := ""
|
||||
for e := l.Front(); e != nil; e = e.Next() {
|
||||
if e.Value != t {
|
||||
// log.Debug("Found")
|
||||
// l.Remove(e)
|
||||
// break
|
||||
// n++
|
||||
nl.PushBack(e.Value)
|
||||
// en := 0
|
||||
// for ee := nl.Front(); ee != nil; ee = ee.Next() {
|
||||
// en++
|
||||
|
||||
// }
|
||||
// if en > nl.Len() {
|
||||
// log.Error("en > ee")
|
||||
// }
|
||||
|
||||
// v := e.Value
|
||||
// if v == nil {
|
||||
// continue
|
||||
// }
|
||||
// m_ := v.(*model.Tunnel)
|
||||
// tn = tn + m_.GetID()
|
||||
}
|
||||
|
||||
}
|
||||
// log.Debug("display tunnels %s", tn)
|
||||
// if n == this.tunnelList.Len() {
|
||||
// m := t.(*model.Tunnel)
|
||||
// log.Debug("check tunntel %s", m.GetID())
|
||||
// }
|
||||
this.tunnelList = nl
|
||||
log.Debug("%d tunnels after remove.", this.tunnelList.Len())
|
||||
|
||||
|
|
@ -126,9 +73,7 @@ func (this *TunnelStatusManager) chanListener() {
|
|||
}
|
||||
|
||||
func (this *TunnelStatusManager) QueryStatString() string {
|
||||
// this.mux.Lock()
|
||||
// defer this.mux.Unlock()
|
||||
mux.Lock()
|
||||
defer mux.Unlock()
|
||||
this.mux.Lock()
|
||||
defer this.mux.Unlock()
|
||||
return fmt.Sprintf("There %d tunnels running.\n", this.tunnelList.Len())
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue