mirror of
https://github.com/ehang-io/nps.git
synced 2025-09-02 11:56:53 +00:00
Revert "change mux data struct, fix #250"
This reverts commit ae28d41231
.
This commit is contained in:
@@ -265,7 +265,7 @@ start:
|
||||
Self.bufQueue.Push(element)
|
||||
// status check finish, now we can push the element into the queue
|
||||
if wait == 0 {
|
||||
Self.mux.sendInfo(common.MUX_MSG_SEND_OK, id, newRemaining)
|
||||
Self.mux.sendInfo(common.MUX_MSG_SEND_OK, id, Self.maxSize, newRemaining)
|
||||
// send the remaining window size, not including zero size
|
||||
}
|
||||
return nil
|
||||
@@ -333,7 +333,7 @@ func (Self *ReceiveWindow) sendStatus(id int32, l uint16) {
|
||||
// now we get the current window status success
|
||||
if wait == 1 {
|
||||
//logs.Warn("send the wait status", remaining)
|
||||
Self.mux.sendInfo(common.MUX_MSG_SEND_OK, id, remaining)
|
||||
Self.mux.sendInfo(common.MUX_MSG_SEND_OK, id, atomic.LoadUint32(&Self.maxSize), remaining)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -394,7 +394,7 @@ func (Self *SendWindow) SetSendBuf(buf []byte) {
|
||||
Self.off = 0
|
||||
}
|
||||
|
||||
func (Self *SendWindow) SetSize(newRemaining uint32) (closed bool) {
|
||||
func (Self *SendWindow) SetSize(windowSize, newRemaining uint32) (closed bool) {
|
||||
// set the window size from receive window
|
||||
defer func() {
|
||||
if recover() != nil {
|
||||
|
@@ -92,13 +92,13 @@ func (s *Mux) Addr() net.Addr {
|
||||
return s.conn.LocalAddr()
|
||||
}
|
||||
|
||||
func (s *Mux) sendInfo(flag uint8, id int32, data interface{}) {
|
||||
func (s *Mux) sendInfo(flag uint8, id int32, data ...interface{}) {
|
||||
if s.IsClose {
|
||||
return
|
||||
}
|
||||
var err error
|
||||
pack := common.MuxPack.Get()
|
||||
err = pack.NewPac(flag, id, data)
|
||||
err = pack.NewPac(flag, id, data...)
|
||||
if err != nil {
|
||||
common.MuxPack.Put(pack)
|
||||
logs.Error("mux: new pack err", err)
|
||||
@@ -173,7 +173,7 @@ func (s *Mux) ping() {
|
||||
s.sendInfo(common.MUX_PING_FLAG, common.MUX_PING, now)
|
||||
// send the ping flag and get the latency first
|
||||
ticker := time.NewTicker(time.Second * 5)
|
||||
defer ticker.Stop()
|
||||
defer ticker.Stop()
|
||||
for {
|
||||
if s.IsClose {
|
||||
break
|
||||
@@ -198,7 +198,7 @@ func (s *Mux) ping() {
|
||||
}
|
||||
atomic.AddUint32(&s.pingOk, 1)
|
||||
}
|
||||
return
|
||||
return
|
||||
}()
|
||||
}
|
||||
|
||||
@@ -297,7 +297,7 @@ func (s *Mux) readSession() {
|
||||
if connection.isClose {
|
||||
continue
|
||||
}
|
||||
connection.sendWindow.SetSize(pack.RemainLength)
|
||||
connection.sendWindow.SetSize(pack.Window, pack.ReadLength)
|
||||
continue
|
||||
case common.MUX_CONN_CLOSE: //close the connection
|
||||
connection.closeFlag = true
|
||||
|
Reference in New Issue
Block a user