File tree Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change 28
28
)
29
29
30
30
func (e * Emitter ) init () {
31
- e .ch = make (chan emitPacket )
31
+ e .ch = make (chan emitPacket , 1 )
32
32
go e .emitTask ()
33
33
}
34
34
Original file line number Diff line number Diff line change @@ -36,9 +36,6 @@ const (
36
36
// maximum packet size
37
37
mtuLimit = 1500
38
38
39
- // packet receiving channel limit
40
- rxQueueLimit = 2048
41
-
42
39
// FEC keeps rxFECMulti* (dataShard+parityShard) ordered packets in memory
43
40
rxFECMulti = 3
44
41
)
@@ -618,7 +615,7 @@ func (s *UDPSession) receiver(ch chan []byte) {
618
615
619
616
// read loop for client session
620
617
func (s * UDPSession ) readLoop () {
621
- chPacket := make (chan []byte , rxQueueLimit )
618
+ chPacket := make (chan []byte , 1 )
622
619
go s .receiver (chPacket )
623
620
624
621
for {
@@ -677,7 +674,7 @@ type (
677
674
678
675
// monitor incoming data for all connections of server
679
676
func (l * Listener ) monitor () {
680
- chPacket := make (chan inPacket , rxQueueLimit )
677
+ chPacket := make (chan inPacket , 1 )
681
678
go l .receiver (chPacket )
682
679
for {
683
680
select {
@@ -741,7 +738,10 @@ func (l *Listener) receiver(ch chan inPacket) {
741
738
for {
742
739
data := xmitBuf .Get ().([]byte )[:mtuLimit ]
743
740
if n , from , err := l .conn .ReadFrom (data ); err == nil && n >= l .headerSize + IKCP_OVERHEAD {
744
- ch <- inPacket {from , data [:n ]}
741
+ select {
742
+ case ch <- inPacket {from , data [:n ]}:
743
+ case <- l .die :
744
+ }
745
745
} else if err != nil {
746
746
return
747
747
} else {
You can’t perform that action at this time.
0 commit comments