Skip to content

Commit

Permalink
Revert to random u64.
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman S. Borschel committed Oct 15, 2020
1 parent f6bb354 commit b98234b
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions muxers/mplex/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,26 @@ use nohash_hasher::{IntMap, IntSet};
use parking_lot::Mutex;
use smallvec::SmallVec;
use std::collections::VecDeque;
use std::{cmp, fmt, io, mem, task::{Context, Poll, Waker}};
use std::sync::{Arc, atomic::{AtomicU32, Ordering}};
use std::{cmp, fmt, io, mem, sync::Arc, task::{Context, Poll, Waker}};

pub use std::io::{Result, Error, ErrorKind};

const NEXT_CONNECTION_ID: AtomicU32 = AtomicU32::new(0);

/// A connection identifier.
///
/// Randomly generated and mainly intended to improve log output
/// by scoping substream IDs to a connection.
#[derive(Clone, Copy)]
struct ConnectionId(u32);
struct ConnectionId(u64);

impl fmt::Debug for ConnectionId {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:04x}", self.0)
write!(f, "{:16x}", self.0)
}
}

impl fmt::Display for ConnectionId {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:04x}", self.0)
write!(f, "{:16x}", self.0)
}
}
/// A multiplexed I/O stream.
Expand Down Expand Up @@ -116,8 +113,8 @@ where
{
/// Creates a new multiplexed I/O stream.
pub fn new(io: C, config: MplexConfig) -> Self {
let id = ConnectionId(NEXT_CONNECTION_ID.fetch_add(1, Ordering::Relaxed));
debug!("New multiplexed stream: {}", id);
let id = ConnectionId(rand::random());
debug!("New multiplexed connection: {}", id);
Multiplexed {
id,
config,
Expand Down

0 comments on commit b98234b

Please sign in to comment.