Skip to content

Commit

Permalink
Fix high CPU reload deadlock in publisher
Browse files Browse the repository at this point in the history
  • Loading branch information
driskell committed Nov 23, 2021
1 parent 2ea3046 commit 51c4d18
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Log Courier / Log Carver

- Fixed crash during configuration reload for `tcp` receiver and transport
- Fixed reload of configuration not correctly updating endpoints
- Fixed reload of configuration sometimes causing a deadlock with hugh CPU

## 2.8.0

Expand Down
8 changes: 8 additions & 0 deletions lc-lib/internallist/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,21 @@ func (l *List) Remove(e *Element) interface{} {
}

// PushFront inserts a new element e at the front of list l and returns e.
// Does nothing and returns e if the item is already in a list.
func (l *List) PushFront(e *Element) *Element {
if e.list != nil {
return e
}
l.lazyInit()
return l.insert(e, &l.root)
}

// PushBack inserts a new element e at the back of list l and returns e.
// Does nothing and returns e if the item is already in a list.
func (l *List) PushBack(e *Element) *Element {
if e.list != nil {
return e
}
l.lazyInit()
return l.insert(e, l.root.prev)
}
Expand Down
4 changes: 2 additions & 2 deletions lc-lib/publisher/endpoint/sink_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (s *Sink) AddEndpointAfter(server string, addressPool *addresspool.Pool, af
if after == nil {
s.orderedList.PushFront(&endpoint.orderedElement)
} else {
s.orderedList.MoveAfter(&endpoint.orderedElement, &after.orderedElement)
s.orderedList.InsertAfter(&endpoint.orderedElement, &after.orderedElement)
}
if s.api != nil {
s.api.AddEntry(server, endpoint.apiEntry())
Expand All @@ -107,7 +107,7 @@ func (s *Sink) FindEndpoint(server string) *Endpoint {
func (s *Sink) MoveEndpointAfter(endpoint *Endpoint, after *Endpoint) {
if after == nil {
s.mutex.Lock()
s.orderedList.PushFront(&endpoint.orderedElement)
s.orderedList.MoveToFront(&endpoint.orderedElement)
s.mutex.Unlock()
return
}
Expand Down

0 comments on commit 51c4d18

Please sign in to comment.