mirror of
https://github.com/aler9/gortsplib
synced 2025-09-29 12:32:10 +08:00
client: fix panic when writing packets after connection error (#681)
* Fix writer nullpointer panic on network reconnect * add additional code and tests --------- Co-authored-by: aler9 <46489434+aler9@users.noreply.github.com>
This commit is contained in:
@@ -10,10 +10,11 @@ import (
|
||||
type asyncProcessor struct {
|
||||
bufferSize int
|
||||
|
||||
running bool
|
||||
buffer *ringbuffer.RingBuffer
|
||||
running bool
|
||||
buffer *ringbuffer.RingBuffer
|
||||
stopError error
|
||||
|
||||
chError chan error
|
||||
stopped chan struct{}
|
||||
}
|
||||
|
||||
func (w *asyncProcessor) initialize() {
|
||||
@@ -22,22 +23,21 @@ func (w *asyncProcessor) initialize() {
|
||||
|
||||
func (w *asyncProcessor) start() {
|
||||
w.running = true
|
||||
w.chError = make(chan error)
|
||||
w.stopped = make(chan struct{})
|
||||
go w.run()
|
||||
}
|
||||
|
||||
func (w *asyncProcessor) stop() {
|
||||
if w.running {
|
||||
w.buffer.Close()
|
||||
<-w.chError
|
||||
<-w.stopped
|
||||
w.running = false
|
||||
}
|
||||
}
|
||||
|
||||
func (w *asyncProcessor) run() {
|
||||
err := w.runInner()
|
||||
w.chError <- err
|
||||
close(w.chError)
|
||||
w.stopError = w.runInner()
|
||||
close(w.stopped)
|
||||
}
|
||||
|
||||
func (w *asyncProcessor) runInner() error {
|
||||
|
Reference in New Issue
Block a user