Merge pull request #2486 from svanharmelen/f-stream-ids
core: reverting a few lines from PR #2406
This commit is contained in:
commit
50be642a08
|
@ -3,9 +3,9 @@ package rpc
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
|
||||||
"net"
|
"net"
|
||||||
"sync"
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hashicorp/yamux"
|
"github.com/hashicorp/yamux"
|
||||||
|
@ -17,6 +17,7 @@ import (
|
||||||
// or accept a connection from, and the broker handles the details of
|
// or accept a connection from, and the broker handles the details of
|
||||||
// holding these channels open while they're being negotiated.
|
// holding these channels open while they're being negotiated.
|
||||||
type muxBroker struct {
|
type muxBroker struct {
|
||||||
|
nextId uint32
|
||||||
session *yamux.Session
|
session *yamux.Session
|
||||||
streams map[uint32]*muxBrokerPending
|
streams map[uint32]*muxBrokerPending
|
||||||
|
|
||||||
|
@ -94,12 +95,9 @@ func (m *muxBroker) Dial(id uint32) (net.Conn, error) {
|
||||||
return stream, nil
|
return stream, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// NextId returns a unique ID to use next. There is no need for seeding the
|
// NextId returns a unique ID to use next.
|
||||||
// rand package as the returned ID's aren't stored or used anywhere outside
|
|
||||||
// the current runtime. So it's perfectly fine to get the same pseudo-random
|
|
||||||
// numbers each time terraform is running.
|
|
||||||
func (m *muxBroker) NextId() uint32 {
|
func (m *muxBroker) NextId() uint32 {
|
||||||
return rand.Uint32()
|
return atomic.AddUint32(&m.nextId, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run starts the brokering and should be executed in a goroutine, since it
|
// Run starts the brokering and should be executed in a goroutine, since it
|
||||||
|
|
Loading…
Reference in New Issue