Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No longer creating temporary stream id pool #103

Merged
merged 2 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions protocol/czar/mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (

// A Stream managed by the multiplexer.
type Stream struct {
idp *Sip
idx uint8
mux *Mux
rbf []byte
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -254,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),
Expand All @@ -265,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)
}
Expand All @@ -276,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
}
2 changes: 1 addition & 1 deletion protocol/czar/sip.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Loading