detached f9d1425

Fix swarm inbox listener close race

commit
f9d14252dc91ca929c2facbeb7da441d419fe7ab
author
patriceckhart · · 2026-05-20 18:31 UTC
parent
b13a9a6
signature
unsigned
refs
tag: v0.1.87
1 file · +10 -2
M internal/swarm/inbox.go +10 -2
@@ -162,6 +162,7 @@ type Listener struct {
162162 active net.Conn
163163 out chan string
164164 done chan struct{}
165+ wg sync.WaitGroup
165166 }
166167
167168 // Listen creates the socket at path and starts accepting. The
@@ -215,7 +216,10 @@ func (l *Listener) Close() error {
215216 }
216217
217218 func (l *Listener) acceptLoop() {
218- defer close(l.out)
219+ defer func() {
220+ l.wg.Wait()
221+ close(l.out)
222+ }()
219223 for {
220224 c, err := l.ln.Accept()
221225 if err != nil {
@@ -234,7 +238,11 @@ func (l *Listener) acceptLoop() {
234238 }
235239 l.active = c
236240 l.mu.Unlock()
237- go l.readLoop(c)
241+ l.wg.Add(1)
242+ go func() {
243+ defer l.wg.Done()
244+ l.readLoop(c)
245+ }()
238246 }
239247 }
240248
@@ -162,6 +162,7 @@ type Listener struct {
162 active net.Conn162 active net.Conn
163 out chan string163 out chan string
164 done chan struct{}164 done chan struct{}
165+ wg sync.WaitGroup
165 }166 }
166 167
167 // Listen creates the socket at path and starts accepting. The168 // Listen creates the socket at path and starts accepting. The
@@ -215,7 +216,10 @@ func (l *Listener) Close() error {
215 }216 }
216 217
217 func (l *Listener) acceptLoop() {218 func (l *Listener) acceptLoop() {
218- defer close(l.out)219+ defer func() {
220+ l.wg.Wait()
221+ close(l.out)
222+ }()
219 for {223 for {
220 c, err := l.ln.Accept()224 c, err := l.ln.Accept()
221 if err != nil {225 if err != nil {
@@ -234,7 +238,11 @@ func (l *Listener) acceptLoop() {
234 }238 }
235 l.active = c239 l.active = c
236 l.mu.Unlock()240 l.mu.Unlock()
237- go l.readLoop(c)241+ l.wg.Add(1)
242+ go func() {
243+ defer l.wg.Done()
244+ l.readLoop(c)
245+ }()
238 }246 }
239 }247 }
240 248

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 476

↑↓ moveenter openesc close