Skip to content

Commit

Permalink
Spawn threads in test_mpc server + debugging tiny_http
Browse files Browse the repository at this point in the history
  • Loading branch information
andyleiserson committed Dec 21, 2024
1 parent e0efbf8 commit e8dfb31
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 20 deletions.
2 changes: 1 addition & 1 deletion ipa-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ thiserror = "1.0"
tikv-jemallocator = { version = "0.6", optional = true, features = ["profiling"] }
tikv-jemalloc-ctl = { version = "0.6", optional = true, features = ["stats"] }
time = { version = "0.3", optional = true }
tiny_http = { version = "0.12", optional = true }
tiny_http = { path = "../../tiny-http", optional = true }
tokio = { version = "1.42", features = ["fs", "rt", "rt-multi-thread", "macros"] }
tokio-rustls = { version = "0.26", optional = true }
tokio-stream = "0.1.14"
Expand Down
34 changes: 19 additions & 15 deletions ipa-core/src/bin/test_mpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{
net::TcpListener,
ops::Add,
os::fd::{FromRawFd, RawFd},
path::PathBuf,
path::PathBuf, thread,
};

use clap::{Parser, Subcommand};
Expand Down Expand Up @@ -262,23 +262,27 @@ fn serve_input(args: ServeInputArgs) {
tracing::info!(target: "request_url", "{}", request.url());

let url = request.url()[1..].to_owned();
let response = if url.contains('/') {
error!(target: "error", "Request URL contains a slash");
not_found()
} else {
match File::open(args.directory.join(&url)) {
Ok(file) => Response::from_file(file).boxed(),
Err(err) => {
if err.kind() != ErrorKind::NotFound {
error!(target: "error", "{err}");
let directory = args.directory.clone();

thread::spawn(move || {
let response = if url.contains('/') {
error!(target: "error", "Request URL contains a slash");
not_found()
} else {
match File::open(directory.join(&url)) {
Ok(file) => Response::from_file(file).boxed(),
Err(err) => {
if err.kind() != ErrorKind::NotFound {
error!(target: "error", "{err}");
}
not_found()
}
not_found()
}
}
};
};

let _ = request.respond(response).map_err(|err| {
error!(target: "error", "{err}");
let _ = request.respond(response).map_err(|err| {
error!(target: "error", "{err}");
});
});
}
}
8 changes: 4 additions & 4 deletions ipa-core/tests/hybrid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ pub const IN_THE_CLEAR_BIN: &str = env!("CARGO_BIN_EXE_in_the_clear");

#[test]
fn test_hybrid() {
const INPUT_SIZE: usize = 100;
const SHARDS: usize = 5;
const INPUT_SIZE: usize = 50_000;
const SHARDS: usize = 2;
const MAX_CONVERSION_VALUE: usize = 5;

let config = HybridQueryParams {
Expand Down Expand Up @@ -149,8 +149,8 @@ fn test_hybrid() {

#[test]
fn test_hybrid_poll() {
const INPUT_SIZE: usize = 100;
const SHARDS: usize = 5;
const INPUT_SIZE: usize = 50_000;
const SHARDS: usize = 2;
const MAX_CONVERSION_VALUE: usize = 5;

let config = HybridQueryParams {
Expand Down

0 comments on commit e8dfb31

Please sign in to comment.