Skip to content

Commit 51c4d18

Browse files
committed
Fix high CPU reload deadlock in publisher
1 parent 2ea3046 commit 51c4d18

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Log Courier / Log Carver
88

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

1213
## 2.8.0
1314

lc-lib/internallist/list.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,21 @@ func (l *List) Remove(e *Element) interface{} {
129129
}
130130

131131
// PushFront inserts a new element e at the front of list l and returns e.
132+
// Does nothing and returns e if the item is already in a list.
132133
func (l *List) PushFront(e *Element) *Element {
134+
if e.list != nil {
135+
return e
136+
}
133137
l.lazyInit()
134138
return l.insert(e, &l.root)
135139
}
136140

137141
// PushBack inserts a new element e at the back of list l and returns e.
142+
// Does nothing and returns e if the item is already in a list.
138143
func (l *List) PushBack(e *Element) *Element {
144+
if e.list != nil {
145+
return e
146+
}
139147
l.lazyInit()
140148
return l.insert(e, l.root.prev)
141149
}

lc-lib/publisher/endpoint/sink_list.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func (s *Sink) AddEndpointAfter(server string, addressPool *addresspool.Pool, af
8383
if after == nil {
8484
s.orderedList.PushFront(&endpoint.orderedElement)
8585
} else {
86-
s.orderedList.MoveAfter(&endpoint.orderedElement, &after.orderedElement)
86+
s.orderedList.InsertAfter(&endpoint.orderedElement, &after.orderedElement)
8787
}
8888
if s.api != nil {
8989
s.api.AddEntry(server, endpoint.apiEntry())
@@ -107,7 +107,7 @@ func (s *Sink) FindEndpoint(server string) *Endpoint {
107107
func (s *Sink) MoveEndpointAfter(endpoint *Endpoint, after *Endpoint) {
108108
if after == nil {
109109
s.mutex.Lock()
110-
s.orderedList.PushFront(&endpoint.orderedElement)
110+
s.orderedList.MoveToFront(&endpoint.orderedElement)
111111
s.mutex.Unlock()
112112
return
113113
}

0 commit comments

Comments
 (0)