diff --git a/swarm.go b/swarm.go index 25f45901780e105ac21f646b9d36ce7a9c202fe7..91e8bd4b1c711ce9c05eaf6680778f112384165a 100644 --- a/swarm.go +++ b/swarm.go @@ -47,6 +47,9 @@ var ErrDialTimeout = errors.New("dial timed out") // communication. The Chan sends/receives Messages, which note the // destination or source Peer. type Swarm struct { + nextConnID uint64 // guarded by atomic + nextStreamID uint64 // guarded by atomic + // Close refcount. This allows us to fully wait for the swarm to be torn // down before continuing. refs sync.WaitGroup @@ -54,9 +57,6 @@ type Swarm struct { local peer.ID peers peerstore.Peerstore - nextConnID uint32 // guarded by atomic - nextStreamID uint32 // guarded by atomic - conns struct { sync.RWMutex m map[peer.ID][]*Conn @@ -213,7 +213,7 @@ func (s *Swarm) addConn(tc transport.CapableConn, dir network.Direction) (*Conn, conn: tc, swarm: s, stat: stat, - id: atomic.AddUint32(&s.nextConnID, 1), + id: atomic.AddUint64(&s.nextConnID, 1), } // we ONLY check upgraded connections here so we can send them a Disconnect message. diff --git a/swarm_conn.go b/swarm_conn.go index 74c0b522ba88655fc1ee1ef458700fa1fe080f9d..3d5f8f3735171282d7b13b506b680cc899c2d027 100644 --- a/swarm_conn.go +++ b/swarm_conn.go @@ -25,7 +25,7 @@ var ErrConnClosed = errors.New("connection closed") // Conn is the connection type used by swarm. In general, you won't use this // type directly. type Conn struct { - id uint32 + id uint64 conn transport.CapableConn swarm *Swarm @@ -209,7 +209,7 @@ func (c *Conn) addStream(ts mux.MuxedStream, dir network.Direction) (*Stream, er stream: ts, conn: c, stat: stat, - id: atomic.AddUint32(&c.swarm.nextStreamID, 1), + id: atomic.AddUint64(&c.swarm.nextStreamID, 1), } c.streams.m[s] = struct{}{} diff --git a/swarm_stream.go b/swarm_stream.go index c09b712a527148fd378ce26653c718097061a00e..a5f0738ad61196c8fe96e3974c590346fefbfdaf 100644 --- a/swarm_stream.go +++ b/swarm_stream.go @@ -17,7 +17,7 @@ var _ network.Stream = &Stream{} // Stream is the stream type used by swarm. In general, you won't use this type // directly. type Stream struct { - id uint32 + id uint64 stream mux.MuxedStream conn *Conn