Skip to content

Commit

Permalink
No longer creating temporary stream id pool
Browse files Browse the repository at this point in the history
  • Loading branch information
mohanson authored Aug 27, 2024
1 parent e6d3c53 commit cfb00ce
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
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

0 comments on commit cfb00ce

Please sign in to comment.