Init
This commit is contained in:
@@ -8,11 +8,15 @@ edition = "2024"
|
||||
# to make the lib name unique and wouldn't conflict with the bin name.
|
||||
# This seems to be only an issue on Windows, see https://github.com/rust-lang/cargo/issues/8519
|
||||
name = "ox_speak_server_lib"
|
||||
crate-type = ["staticlib", "cdylib", "rlib"]
|
||||
crate-type = ["rlib"]
|
||||
|
||||
[workspace]
|
||||
members = [".", "migration"]
|
||||
|
||||
[profile.dev]
|
||||
debug = 1 # au lieu de 2 (par défaut) -> PDB beaucoup plus petit
|
||||
incremental = true # utile pour la rapidité, pas toujours pour la RAM mais aide souvent
|
||||
|
||||
[profile.release]
|
||||
#debug = true
|
||||
# poid minimal, rapidité baissé
|
||||
|
||||
3440
frontend/yarn.lock
3440
frontend/yarn.lock
File diff suppressed because it is too large
Load Diff
@@ -6,6 +6,7 @@ use std::io;
|
||||
use tokio::net::UdpSocket;
|
||||
use parking_lot::RwLock;
|
||||
use tokio::task;
|
||||
use crate::utils::toolbox::number_of_cpus;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct UDPServer {
|
||||
@@ -44,7 +45,7 @@ impl UDPServer {
|
||||
|
||||
let mut workers = Vec::new();
|
||||
|
||||
for id in available_parallelism() {
|
||||
for id in 0..number_of_cpus() {
|
||||
let bind_addr = self.bind_addr.clone();
|
||||
|
||||
let domain = match bind_addr {
|
||||
@@ -60,6 +61,7 @@ impl UDPServer {
|
||||
let std_sock = std::net::UdpSocket::from(sock);
|
||||
std_sock.set_nonblocking(true)?;
|
||||
let udp = UdpSocket::from_std(std_sock)?;
|
||||
let udp = Arc::new(udp);
|
||||
|
||||
let buffer_size = 1500;
|
||||
let worker = task::spawn(async move {
|
||||
@@ -82,12 +84,13 @@ impl UDPServer {
|
||||
let udp = UdpSocket::bind(self.bind_addr).await?;
|
||||
let udp = Arc::new(udp);
|
||||
|
||||
let mut workers = Vec::with_capacity(self.workers);
|
||||
for id in 0..self.workers {
|
||||
|
||||
let mut workers = Vec::new();
|
||||
for id in 0..number_of_cpus() {
|
||||
let sock = udp.clone();
|
||||
let buf_size = 1500;
|
||||
let buffer_size = 1500;
|
||||
let worker = task::spawn(async move {
|
||||
if let Err(e) = Self::worker_loop(udp, buffer_size) {
|
||||
if let Err(e) = Self::worker_loop(sock, buffer_size).await {
|
||||
eprintln!("Worker loop error: {}", e);
|
||||
}
|
||||
});
|
||||
@@ -100,7 +103,7 @@ impl UDPServer {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn worker_loop(socket: UdpSocket, buffer_size: usize) -> io::Result<()>{
|
||||
async fn worker_loop(socket: Arc<UdpSocket>, buffer_size: usize) -> io::Result<()>{
|
||||
let mut buffer = vec![0u8; buffer_size];
|
||||
loop {
|
||||
let (size, peer) = socket.recv_from(&mut buffer).await?;
|
||||
|
||||
Reference in New Issue
Block a user