Skip to content

Commit 4ee1a77

Browse files
committed
fix #273
1 parent 0b3010f commit 4ee1a77

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

sess.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,7 @@ func (s *UDPSession) Control(f func(conn net.PacketConn) error) error {
610610
func (s *UDPSession) postProcess() {
611611
txqueue := make([]ipv4.Message, 0, acceptBacklog)
612612
chCork := make(chan struct{}, 1)
613+
chDie := s.die
613614

614615
for {
615616
select {
@@ -668,6 +669,9 @@ func (s *UDPSession) postProcess() {
668669
}
669670
}
670671

672+
// re-eanble die channel
673+
chDie = s.die
674+
671675
case <-chCork: // emulate a corked socket
672676
if len(txqueue) > 0 {
673677
s.tx(txqueue)
@@ -679,7 +683,15 @@ func (s *UDPSession) postProcess() {
679683
txqueue = txqueue[:0]
680684
}
681685

682-
case <-s.die:
686+
// re-eanble die channel
687+
chDie = s.die
688+
689+
case <-chDie:
690+
// remaining packets in txqueue should be sent out
691+
if len(chCork) > 0 || len(s.chPostProcessing) > 0 {
692+
chDie = nil // block chDie
693+
continue
694+
}
683695
return
684696
}
685697
}

0 commit comments

Comments
 (0)