upd deps to smux

This commit is contained in:
xtaci
2023-02-12 20:10:15 +08:00
parent 86f2e5b066
commit ec099786cb
5 changed files with 22 additions and 5 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ require (
github.com/pkg/errors v0.9.1
github.com/urfave/cli v1.22.12
github.com/xtaci/kcp-go/v5 v5.6.2
github.com/xtaci/smux v1.5.19
github.com/xtaci/smux v1.5.20
github.com/xtaci/tcpraw v1.2.25
golang.org/x/crypto v0.5.0
)
+2
View File
@@ -74,6 +74,8 @@ github.com/xtaci/smux v1.5.18 h1:NRH2dIxcO1w5dsNpQxSrxfhxjk4YNg6TrS/Nj0FuUPc=
github.com/xtaci/smux v1.5.18/go.mod h1:OMlQbT5vcgl2gb49mFkYo6SMf+zP3rcjcwQz7ZU7IGY=
github.com/xtaci/smux v1.5.19 h1:QFoVBZPuJnoTs8QQ52TO2469nz8KxGHDpiEb+s3QzCQ=
github.com/xtaci/smux v1.5.19/go.mod h1:OMlQbT5vcgl2gb49mFkYo6SMf+zP3rcjcwQz7ZU7IGY=
github.com/xtaci/smux v1.5.20 h1:7pw7PLSW1MfiiRVBB27T5cFLGws1GAJP9ZDP+V+40dw=
github.com/xtaci/smux v1.5.20/go.mod h1:OMlQbT5vcgl2gb49mFkYo6SMf+zP3rcjcwQz7ZU7IGY=
github.com/xtaci/tcpraw v1.2.25 h1:VDlqo0op17JeXBM6e2G9ocCNLOJcw9mZbobMbJjo0vk=
github.com/xtaci/tcpraw v1.2.25/go.mod h1:dKyZ2V75s0cZ7cbgJYdxPvms7af0joIeOyx1GgJQbLk=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
+16 -1
View File
@@ -13,6 +13,7 @@ import (
const (
defaultAcceptBacklog = 1024
maxShaperSize = 1024
)
var (
@@ -420,8 +421,10 @@ func (s *Session) shaperLoop() {
var reqs shaperHeap
var next writeRequest
var chWrite chan writeRequest
var chShaper chan writeRequest
for {
// chWrite is not available until it has packet to send
if len(reqs) > 0 {
chWrite = s.writes
next = heap.Pop(&reqs).(writeRequest)
@@ -429,10 +432,22 @@ func (s *Session) shaperLoop() {
chWrite = nil
}
// control heap size, chShaper is not available until packets are less than maximum allowed
if len(reqs) >= maxShaperSize {
chShaper = nil
} else {
chShaper = s.shaper
}
// assertion on non nil
if chShaper == nil && chWrite == nil {
panic("both channel are nil")
}
select {
case <-s.die:
return
case r := <-s.shaper:
case r := <-chShaper:
if chWrite != nil { // next is valid, reshape
heap.Push(&reqs, next)
}
+2 -2
View File
@@ -325,7 +325,7 @@ func (s *Stream) Write(b []byte) (n int, err error) {
}
frame.data = bts[:sz]
bts = bts[sz:]
n, err := s.sess.writeFrameInternal(frame, deadline, s.numWritten)
n, err := s.sess.writeFrameInternal(frame, deadline, 0)
s.numWritten++
sent += n
if err != nil {
@@ -393,7 +393,7 @@ func (s *Stream) writeV2(b []byte) (n int, err error) {
}
frame.data = bts[:sz]
bts = bts[sz:]
n, err := s.sess.writeFrameInternal(frame, deadline, atomic.LoadUint32(&s.numWritten))
n, err := s.sess.writeFrameInternal(frame, deadline, 0)
atomic.AddUint32(&s.numWritten, uint32(sz))
sent += n
if err != nil {
+1 -1
View File
@@ -38,7 +38,7 @@ github.com/urfave/cli
# github.com/xtaci/kcp-go/v5 v5.6.2
## explicit; go 1.13
github.com/xtaci/kcp-go/v5
# github.com/xtaci/smux v1.5.19
# github.com/xtaci/smux v1.5.20
## explicit; go 1.13
github.com/xtaci/smux
# github.com/xtaci/tcpraw v1.2.25