X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=core%2Fstream.go;h=363cc9f944d16640115a670a295313712e02469d;hb=c09ee3241377aae2530a73d48c4e20641d76d0ee;hp=3d417f16d65dafef3e9b14fbc6bfd3bf467856fa;hpb=debc52dea8a81417bb08ca5bb934c7876b6d65e0;p=govpp.git diff --git a/core/stream.go b/core/stream.go index 3d417f1..363cc9f 100644 --- a/core/stream.go +++ b/core/stream.go @@ -20,14 +20,12 @@ import ( "fmt" "reflect" "sync" - "sync/atomic" "time" "git.fd.io/govpp.git/api" ) type Stream struct { - id uint32 conn *Connection ctx context.Context channel *Channel @@ -57,15 +55,9 @@ func (c *Connection) NewStream(ctx context.Context, options ...api.StreamOption) for _, option := range options { option(s) } - // create and store a new channel - s.id = atomic.AddUint32(&c.maxChannelID, 1) & 0x7fff - s.channel = newChannel(uint16(s.id), c, c.codec, c, s.requestSize, s.replySize) - s.channel.SetReplyTimeout(s.replyTimeout) - // store API channel within the client - c.channelsLock.Lock() - c.channels[uint16(s.id)] = s.channel - c.channelsLock.Unlock() + s.channel = c.newChannel(s.requestSize, s.replySize) + s.channel.SetReplyTimeout(s.replyTimeout) // Channel.watchRequests are not started here intentionally, because // requests are sent directly by SendMsg.