From 1d383b64a98e06b2fdbf9757cb3fe3218a2373ea Mon Sep 17 00:00:00 2001 From: mohanson Date: Tue, 27 Aug 2024 11:06:34 +0800 Subject: [PATCH 1/2] 2024-08-27 11:06:34 --- protocol/czar/mux.go | 9 ++------- protocol/czar/sip.go | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/protocol/czar/mux.go b/protocol/czar/mux.go index 92a9d65..1d6cba9 100644 --- a/protocol/czar/mux.go +++ b/protocol/czar/mux.go @@ -11,7 +11,6 @@ import ( // A Stream managed by the multiplexer. type Stream struct { - idp *Sip idx uint8 mux *Mux rbf []byte @@ -46,7 +45,7 @@ func (s *Stream) Esolc() error { }) }) s.zo1.Do(func() { - s.idp.Put(s.idx) + s.mux.idp.Put(s.idx) }) return nil } @@ -120,7 +119,6 @@ func (s *Stream) Write(p []byte) (int, error) { // NewStream returns a new Stream. func NewStream(idx uint8, mux *Mux) *Stream { return &Stream{ - idp: nil, idx: idx, mux: mux, rbf: make([]byte, 0), @@ -181,7 +179,6 @@ func (m *Mux) Open() (*Stream, error) { return nil, err } stm = NewStream(idx, m) - stm.idp = m.idp m.usb[idx] = stm return stm, nil } @@ -215,9 +212,7 @@ func (m *Mux) Recv() { break } stm = NewStream(idx, m) - // The mux server does not need to using an id pool. - stm.idp = m.idp - stm.idp.Set(idx) + m.idp.Set(idx) m.usb[idx] = stm m.ach <- stm case cmd == 0x01: diff --git a/protocol/czar/sip.go b/protocol/czar/sip.go index a4482ae..84cb7b4 100644 --- a/protocol/czar/sip.go +++ b/protocol/czar/sip.go @@ -43,7 +43,7 @@ func (s *Sip) Set(x uint8) { s.i = s.i.SetBit(s.i, int(x), 1) } -// NewSip returns a new sid. +// NewSip returns a new sip. func NewSip() *Sip { return &Sip{ i: big.NewInt(0), From 5b319068039338043313ba4f4d7539567e429764 Mon Sep 17 00:00:00 2001 From: mohanson Date: Tue, 27 Aug 2024 11:13:22 +0800 Subject: [PATCH 2/2] 2024-08-27 11:13:22 --- protocol/czar/mux.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/protocol/czar/mux.go b/protocol/czar/mux.go index 1d6cba9..f61b987 100644 --- a/protocol/czar/mux.go +++ b/protocol/czar/mux.go @@ -249,7 +249,7 @@ func NewMux(conn net.Conn) *Mux { mux := &Mux{ ach: make(chan *Stream), con: conn, - idp: nil, + idp: NewSip(), pri: NewPriority(), rer: NewErr(), usb: make([]*Stream, 256), @@ -260,7 +260,6 @@ func NewMux(conn net.Conn) *Mux { // NewMuxServer returns a new MuxServer. func NewMuxServer(conn net.Conn) *Mux { mux := NewMux(conn) - mux.idp = NewSip() for i := range 256 { mux.usb[i] = NewWither(uint8(i), mux) } @@ -271,7 +270,6 @@ func NewMuxServer(conn net.Conn) *Mux { // NewMuxClient returns a new MuxClient. func NewMuxClient(conn net.Conn) *Mux { mux := NewMux(conn) - mux.idp = NewSip() go mux.Recv() return mux }