Skip to content

Commit

Permalink
fix #273
Browse files Browse the repository at this point in the history
  • Loading branch information
xtaci committed Aug 28, 2024
1 parent 0b3010f commit 4ee1a77
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion sess.go
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@ func (s *UDPSession) Control(f func(conn net.PacketConn) error) error {
func (s *UDPSession) postProcess() {
txqueue := make([]ipv4.Message, 0, acceptBacklog)
chCork := make(chan struct{}, 1)
chDie := s.die

for {
select {
Expand Down Expand Up @@ -668,6 +669,9 @@ func (s *UDPSession) postProcess() {
}
}

// re-eanble die channel
chDie = s.die

case <-chCork: // emulate a corked socket
if len(txqueue) > 0 {
s.tx(txqueue)
Expand All @@ -679,7 +683,15 @@ func (s *UDPSession) postProcess() {
txqueue = txqueue[:0]
}

case <-s.die:
// re-eanble die channel
chDie = s.die

case <-chDie:
// remaining packets in txqueue should be sent out
if len(chCork) > 0 || len(s.chPostProcessing) > 0 {
chDie = nil // block chDie
continue
}
return
}
}
Expand Down

0 comments on commit 4ee1a77

Please sign in to comment.