|
@@ -202,6 +202,7 @@ type ReceiveWindow struct {
|
|
bufQueue ReceiveWindowQueue
|
|
bufQueue ReceiveWindowQueue
|
|
element *common.ListElement
|
|
element *common.ListElement
|
|
count int8
|
|
count int8
|
|
|
|
+ bw *bandwidth
|
|
once sync.Once
|
|
once sync.Once
|
|
|
|
|
|
|
|
|
|
@@ -211,9 +212,10 @@ func (Self *ReceiveWindow) New(mux *Mux) {
|
|
|
|
|
|
Self.bufQueue.New()
|
|
Self.bufQueue.New()
|
|
Self.element = common.ListElementPool.Get()
|
|
Self.element = common.ListElementPool.Get()
|
|
- Self.maxSizeDone = Self.pack(common.MAXIMUM_SEGMENT_SIZE*10, 0, false)
|
|
+ Self.maxSizeDone = Self.pack(common.MAXIMUM_SEGMENT_SIZE*30, 0, false)
|
|
Self.mux = mux
|
|
Self.mux = mux
|
|
Self.window.New()
|
|
Self.window.New()
|
|
|
|
+ Self.bw = NewBandwidth(nil)
|
|
}
|
|
}
|
|
|
|
|
|
func (Self *ReceiveWindow) remainingSize(maxSize uint32, delta uint16) (n uint32) {
|
|
func (Self *ReceiveWindow) remainingSize(maxSize uint32, delta uint16) (n uint32) {
|
|
@@ -232,10 +234,11 @@ func (Self *ReceiveWindow) calcSize() {
|
|
|
|
|
|
conns := Self.mux.connMap.Size()
|
|
conns := Self.mux.connMap.Size()
|
|
n := uint32(math.Float64frombits(atomic.LoadUint64(&Self.mux.latency)) *
|
|
n := uint32(math.Float64frombits(atomic.LoadUint64(&Self.mux.latency)) *
|
|
- Self.mux.bw.Get() / float64(conns))
|
|
+ (Self.mux.bw.Get() + Self.bw.Get()))
|
|
|
|
|
|
- if n < common.MAXIMUM_SEGMENT_SIZE*10 {
|
|
+ if n < common.MAXIMUM_SEGMENT_SIZE*30 {
|
|
- n = common.MAXIMUM_SEGMENT_SIZE * 10
|
|
+
|
|
|
|
+ n = common.MAXIMUM_SEGMENT_SIZE * 30
|
|
}
|
|
}
|
|
for {
|
|
for {
|
|
ptrs := atomic.LoadUint64(&Self.maxSizeDone)
|
|
ptrs := atomic.LoadUint64(&Self.maxSizeDone)
|
|
@@ -313,6 +316,13 @@ func (Self *ReceiveWindow) Read(p []byte, id int32) (n int, err error) {
|
|
if Self.closeOp {
|
|
if Self.closeOp {
|
|
return 0, io.EOF
|
|
return 0, io.EOF
|
|
}
|
|
}
|
|
|
|
+ Self.bw.StartRead()
|
|
|
|
+ n, err = Self.readFromQueue(p, id)
|
|
|
|
+ Self.bw.SetCopySize(uint16(n))
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (Self *ReceiveWindow) readFromQueue(p []byte, id int32) (n int, err error) {
|
|
pOff := 0
|
|
pOff := 0
|
|
l := 0
|
|
l := 0
|
|
|
|
|
|
@@ -363,7 +373,7 @@ func (Self *ReceiveWindow) sendStatus(id int32, l uint16) {
|
|
if read <= (read+uint32(l))&mask31 {
|
|
if read <= (read+uint32(l))&mask31 {
|
|
read += uint32(l)
|
|
read += uint32(l)
|
|
remain := Self.remainingSize(maxSize, 0)
|
|
remain := Self.remainingSize(maxSize, 0)
|
|
- if wait && remain > 0 || remain == maxSize {
|
|
+ if wait && remain > 0 || read >= maxSize/2 || remain == maxSize {
|
|
if atomic.CompareAndSwapUint64(&Self.maxSizeDone, ptrs, Self.pack(maxSize, 0, false)) {
|
|
if atomic.CompareAndSwapUint64(&Self.maxSizeDone, ptrs, Self.pack(maxSize, 0, false)) {
|
|
|
|
|
|
|
|
|
|
@@ -441,7 +451,7 @@ type SendWindow struct {
|
|
|
|
|
|
func (Self *SendWindow) New(mux *Mux) {
|
|
func (Self *SendWindow) New(mux *Mux) {
|
|
Self.setSizeCh = make(chan struct{})
|
|
Self.setSizeCh = make(chan struct{})
|
|
- Self.maxSizeDone = Self.pack(common.MAXIMUM_SEGMENT_SIZE*10, 0, false)
|
|
+ Self.maxSizeDone = Self.pack(common.MAXIMUM_SEGMENT_SIZE*30, 0, false)
|
|
Self.mux = mux
|
|
Self.mux = mux
|
|
Self.window.New()
|
|
Self.window.New()
|
|
}
|
|
}
|
|
@@ -654,82 +664,3 @@ func (Self *SendWindow) SetTimeOut(t time.Time) {
|
|
|
|
|
|
Self.timeout = t
|
|
Self.timeout = t
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|