File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ package kcp
4
4
5
5
import (
6
6
"net"
7
+ "os"
7
8
"sync/atomic"
8
9
9
10
"github.com/pkg/errors"
@@ -47,6 +48,17 @@ func (s *UDPSession) readLoop() {
47
48
s .packetInput (msg .Buffers [0 ][:msg .N ])
48
49
}
49
50
} else {
51
+ // compatibility issue:
52
+ // for linux kernel<=2.6.32, support for sendmmsg is not available
53
+ // an error of type os.SyscallError will be returned
54
+ if operr , ok := err .(* net.OpError ); ok {
55
+ if se , ok := operr .Err .(* os.SyscallError ); ok {
56
+ if se .Syscall == "recvmmsg" {
57
+ s .defaultReadLoop ()
58
+ return
59
+ }
60
+ }
61
+ }
50
62
s .notifyReadError (errors .WithStack (err ))
51
63
return
52
64
}
@@ -90,6 +102,17 @@ func (l *Listener) monitor() {
90
102
}
91
103
}
92
104
} else {
105
+ // compatibility issue:
106
+ // for linux kernel<=2.6.32, support for sendmmsg is not available
107
+ // an error of type os.SyscallError will be returned
108
+ if operr , ok := err .(* net.OpError ); ok {
109
+ if se , ok := operr .Err .(* os.SyscallError ); ok {
110
+ if se .Syscall == "recvmmsg" {
111
+ l .defaultMonitor ()
112
+ return
113
+ }
114
+ }
115
+ }
93
116
l .notifyReadError (errors .WithStack (err ))
94
117
return
95
118
}
Original file line number Diff line number Diff line change 3
3
package kcp
4
4
5
5
import (
6
+ "net"
7
+ "os"
6
8
"sync/atomic"
7
9
8
10
"github.com/pkg/errors"
@@ -28,6 +30,18 @@ func (s *UDPSession) tx(txqueue []ipv4.Message) {
28
30
npkts += n
29
31
txqueue = txqueue [n :]
30
32
} else {
33
+ // compatibility issue:
34
+ // for linux kernel<=2.6.32, support for sendmmsg is not available
35
+ // an error of type os.SyscallError will be returned
36
+ if operr , ok := err .(* net.OpError ); ok {
37
+ if se , ok := operr .Err .(* os.SyscallError ); ok {
38
+ if se .Syscall == "sendmmsg" {
39
+ s .xconn = nil // set s.xconn to nil permanently
40
+ s .defaultTx (txqueue )
41
+ return
42
+ }
43
+ }
44
+ }
31
45
s .notifyWriteError (errors .WithStack (err ))
32
46
break
33
47
}
You can’t perform that action at this time.
0 commit comments