mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-07-09 06:14:06 +00:00
Fix panic: send on closed channel
This commit is contained in:
parent
57d0584655
commit
173ef83064
@ -2,6 +2,7 @@ package tlstapper
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/up9inc/mizu/tap/api"
|
"github.com/up9inc/mizu/tap/api"
|
||||||
@ -20,6 +21,7 @@ type golangReader struct {
|
|||||||
counterPair *api.CounterPair
|
counterPair *api.CounterPair
|
||||||
parent *tlsStream
|
parent *tlsStream
|
||||||
reqResMatcher api.RequestResponseMatcher
|
reqResMatcher api.RequestResponseMatcher
|
||||||
|
sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewGolangReader(extension *api.Extension, isClient bool, emitter api.Emitter, counterPair *api.CounterPair, stream *tlsStream, reqResMatcher api.RequestResponseMatcher) *golangReader {
|
func NewGolangReader(extension *api.Extension, isClient bool, emitter api.Emitter, counterPair *api.CounterPair, stream *tlsStream, reqResMatcher api.RequestResponseMatcher) *golangReader {
|
||||||
@ -38,15 +40,21 @@ func NewGolangReader(extension *api.Extension, isClient bool, emitter api.Emitte
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *golangReader) send(b []byte) {
|
func (r *golangReader) send(b []byte) {
|
||||||
r.captureTime = time.Now()
|
r.Lock()
|
||||||
r.msgQueue <- b
|
if !r.isClosed {
|
||||||
|
r.captureTime = time.Now()
|
||||||
|
r.msgQueue <- b
|
||||||
|
}
|
||||||
|
r.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *golangReader) close() {
|
func (r *golangReader) close() {
|
||||||
|
r.Lock()
|
||||||
if !r.isClosed {
|
if !r.isClosed {
|
||||||
r.isClosed = true
|
r.isClosed = true
|
||||||
close(r.msgQueue)
|
close(r.msgQueue)
|
||||||
}
|
}
|
||||||
|
r.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *golangReader) Read(p []byte) (int, error) {
|
func (r *golangReader) Read(p []byte) (int, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user