Commit 1f73ae2b authored by nanamicat's avatar nanamicat

BTreeMap

parent dc2030f9
Pipeline #42038 failed with stages
in 2 minutes and 13 seconds
......@@ -2,7 +2,7 @@ mod config;
mod router;
use crate::config::{Config, Schema};
use crate::router::{Meta, Router, META_SIZE};
use crate::router::Router;
use anyhow::{Context, Result};
use crossbeam::epoch::{pin, Owned};
use crossbeam_utils::thread;
......@@ -11,7 +11,7 @@ use std::collections::BTreeMap;
use std::net::Shutdown;
use std::sync::atomic::Ordering;
use std::time::Duration;
use std::{env, mem::MaybeUninit};
use std::env;
fn main() -> Result<()> {
println!("Starting");
......@@ -75,16 +75,13 @@ fn main() -> Result<()> {
let (connection, _) = socket.accept().unwrap();
s.spawn(move |_| {
connection.set_tcp_nodelay(true).unwrap();
let mut meta_bytes = [MaybeUninit::uninit(); META_SIZE];
let mut meta_bytes = [0u8; 2];
Router::recv_exact_tcp(&connection, &mut meta_bytes).unwrap();
let meta: &Meta = Meta::from_bytes(&meta_bytes);
if meta.reversed == 0
&& let Some(router) = routers.get(&meta.src_id)
&& meta.dst_id == router.config.local_id
let src_id = meta_bytes[0];
let dst_id = meta_bytes[1];
if let Some(router) = routers.get(&src_id)
&& dst_id == router.config.local_id
{
// let connection = Arc::new(connection);
// tcp listener 只许一个连接,过来新连接就把前一个关掉。
{
let guard = pin();
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment