evdist: Fix some segv
This commit is contained in:
parent
7a5c1eeba7
commit
e922171f17
2 changed files with 36 additions and 3 deletions
|
@ -71,6 +71,30 @@ func (l *distList) AddEvent(nsf *settings.NextSettingsFile) {
|
|||
}
|
||||
}
|
||||
|
||||
func (l *distList) DelEvent(id int64) {
|
||||
l.Lock.Lock()
|
||||
|
||||
istop := len(l.List)
|
||||
for i, n := range l.List {
|
||||
if n.Id == id {
|
||||
istop = i
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if istop == len(l.List)-1 {
|
||||
l.List = l.List[:istop]
|
||||
} else if istop != len(l.List) {
|
||||
l.List = append(l.List[:istop], l.List[istop+1:]...)
|
||||
}
|
||||
|
||||
l.Lock.Unlock()
|
||||
|
||||
if istop == 0 {
|
||||
l.ResetTimer()
|
||||
}
|
||||
}
|
||||
|
||||
func (l *distList) ResetTimer() {
|
||||
l.Lock.RLock()
|
||||
defer l.Lock.RUnlock()
|
||||
|
|
Reference in a new issue