stop doing anything after being released. fixes #804

pull/1162/head
Darien Raymond 2018-02-25 22:13:42 +01:00
parent caa52e9327
commit 4783b8f2c6
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
1 changed files with 16 additions and 1 deletions

View File

@ -191,11 +191,12 @@ type SendingWorker struct {
conn *Connection
window *SendingWindow
firstUnacknowledged uint32
firstUnacknowledgedUpdated bool
nextNumber uint32
remoteNextNumber uint32
controlWindow uint32
fastResend uint32
firstUnacknowledgedUpdated bool
closed bool
}
func NewSendingWorker(kcp *Connection) *SendingWorker {
@ -212,6 +213,7 @@ func NewSendingWorker(kcp *Connection) *SendingWorker {
func (w *SendingWorker) Release() {
w.Lock()
w.window.Release()
w.closed = true
w.Unlock()
}
@ -258,6 +260,10 @@ func (w *SendingWorker) ProcessSegment(current uint32, seg *AckSegment, rto uint
w.Lock()
defer w.Unlock()
if w.closed {
return
}
if w.remoteNextNumber < seg.ReceivingWindow {
w.remoteNextNumber = seg.ReceivingWindow
}
@ -289,6 +295,10 @@ func (w *SendingWorker) Push(f buf.Supplier) bool {
w.Lock()
defer w.Unlock()
if w.closed {
return false
}
if w.window.IsFull() {
return false
}
@ -333,6 +343,11 @@ func (w *SendingWorker) OnPacketLoss(lossRate uint32) {
func (w *SendingWorker) Flush(current uint32) {
w.Lock()
if w.closed {
w.Unlock()
return
}
cwnd := w.firstUnacknowledged + w.conn.Config.GetSendingInFlightSize()
if cwnd > w.remoteNextNumber {
cwnd = w.remoteNextNumber