Skip to content

Commit f3fca60

Browse files
Jacob SchuenkeTravis Patterson
authored andcommitted
fix goroutine leak
Signed-off-by: Travis Patterson <tpatterson@pivotal.io>
1 parent e9726b5 commit f3fca60

File tree

1 file changed

+6
-7
lines changed
  • src/rlp-gateway/internal/web

1 file changed

+6
-7
lines changed

src/rlp-gateway/internal/web/read.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ func ReadHandler(
4545
http.Error(w, err.Error(), http.StatusBadRequest)
4646
return
4747
}
48-
4948
flusher, ok := w.(http.Flusher)
5049
if !ok {
5150
errStreamingUnsupported.Write(w)
@@ -69,14 +68,10 @@ func ReadHandler(
6968
)
7069

7170
data := make(chan *loggregator_v2.EnvelopeBatch)
72-
errs := make(chan error)
71+
errs := make(chan error, 1)
7372

7473
go func() {
7574
for {
76-
if isDone(ctx) {
77-
return
78-
}
79-
8075
batch, err := recv()
8176
if err != nil {
8277
errs <- err
@@ -87,7 +82,11 @@ func ReadHandler(
8782
continue
8883
}
8984

90-
data <- batch
85+
select {
86+
case data <- batch:
87+
case <-ctx.Done():
88+
return
89+
}
9190
}
9291
}()
9392

0 commit comments

Comments
 (0)