mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-18 12:16:31 +00:00
@ -11,7 +11,7 @@
|
||||
#define MAX_REQUEST_SIZE 1500
|
||||
#define MAX_RESPONSE_SIZE 1500
|
||||
// 网页根目录
|
||||
#define WEB_ROOT "/wwwroot/First-WebPage-On-DragonOS"
|
||||
#define WEB_ROOT "/var/www/html/"
|
||||
#define EXIT_CODE 1
|
||||
#define min(a, b) ((a) < (b) ? (a) : (b))
|
||||
|
||||
|
2
user/apps/test-backlog/.cargo/config.toml
Normal file
2
user/apps/test-backlog/.cargo/config.toml
Normal file
@ -0,0 +1,2 @@
|
||||
[build]
|
||||
target = "x86_64-unknown-linux-musl"
|
3
user/apps/test-backlog/.gitignore
vendored
Normal file
3
user/apps/test-backlog/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
/target
|
||||
Cargo.lock
|
||||
/install/
|
12
user/apps/test-backlog/Cargo.toml
Normal file
12
user/apps/test-backlog/Cargo.toml
Normal file
@ -0,0 +1,12 @@
|
||||
[package]
|
||||
name = "test-backlog"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
description = "test the tcp backlog"
|
||||
authors = [ "saga" ]
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
actix-web={ version = "3.0.0",default-features = false,features=["rust-tls"] }
|
||||
|
56
user/apps/test-backlog/Makefile
Normal file
56
user/apps/test-backlog/Makefile
Normal file
@ -0,0 +1,56 @@
|
||||
TOOLCHAIN="+nightly-2023-08-15-x86_64-unknown-linux-gnu"
|
||||
RUSTFLAGS+=""
|
||||
|
||||
ifdef DADK_CURRENT_BUILD_DIR
|
||||
# 如果是在dadk中编译,那么安装到dadk的安装目录中
|
||||
INSTALL_DIR = $(DADK_CURRENT_BUILD_DIR)
|
||||
else
|
||||
# 如果是在本地编译,那么安装到当前目录下的install目录中
|
||||
INSTALL_DIR = ./install
|
||||
endif
|
||||
|
||||
ifeq ($(ARCH), x86_64)
|
||||
export RUST_TARGET=x86_64-unknown-linux-musl
|
||||
else ifeq ($(ARCH), riscv64)
|
||||
export RUST_TARGET=riscv64gc-unknown-linux-gnu
|
||||
else
|
||||
# 默认为x86_86,用于本地编译
|
||||
export RUST_TARGET=x86_64-unknown-linux-musl
|
||||
endif
|
||||
|
||||
run:
|
||||
RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) run --target $(RUST_TARGET) --features"rust-tls"
|
||||
|
||||
build:
|
||||
RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) build --target $(RUST_TARGET) --features"rust-tls"
|
||||
|
||||
clean:
|
||||
RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) clean --target $(RUST_TARGET)
|
||||
|
||||
test:
|
||||
RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) test --target $(RUST_TARGET)
|
||||
|
||||
doc:
|
||||
RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) doc --target $(RUST_TARGET)
|
||||
|
||||
fmt:
|
||||
RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) fmt
|
||||
|
||||
fmt-check:
|
||||
RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) fmt --check
|
||||
|
||||
run-release:
|
||||
RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) run --target $(RUST_TARGET) --release
|
||||
|
||||
build-release:
|
||||
RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) build --target $(RUST_TARGET) --release
|
||||
|
||||
clean-release:
|
||||
RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) clean --target $(RUST_TARGET) --release
|
||||
|
||||
test-release:
|
||||
RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) test --target $(RUST_TARGET) --release
|
||||
|
||||
.PHONY: install
|
||||
install:
|
||||
RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) install --target $(RUST_TARGET) --path . --no-track --root $(INSTALL_DIR) --force
|
9
user/apps/test-backlog/README.md
Normal file
9
user/apps/test-backlog/README.md
Normal file
@ -0,0 +1,9 @@
|
||||
## 程序说明
|
||||
用于测试tcp的backlog功能的测试程序
|
||||
本程序绑定到0.0.0.0:12580端口,并在外部手动多线程请求这个端口来测试backlog功能
|
||||
|
||||
## 使用方法
|
||||
|
||||
1. 打开系统的/bin目录
|
||||
2. 输入指令exec test-backlog即可开始测试
|
||||
3. 可以在外部使用apifox进行多次请求,当请求数目超过backlog时会有几个请求失败
|
33
user/apps/test-backlog/src/main.rs
Normal file
33
user/apps/test-backlog/src/main.rs
Normal file
@ -0,0 +1,33 @@
|
||||
use actix_web::{web, App, HttpRequest, HttpResponse, HttpServer};
|
||||
use std::io;
|
||||
|
||||
async fn index(req: HttpRequest) -> HttpResponse {
|
||||
// 获取请求方法
|
||||
let method = req.method().to_string();
|
||||
// 获取请求路径
|
||||
let path = req.path().to_string();
|
||||
// 获取请求头部信息
|
||||
let headers = req.headers().clone();
|
||||
// 获取查询参数
|
||||
let query_params = req.query_string().to_string();
|
||||
|
||||
// 打印请求信息
|
||||
println!("Received {} request to {}", method, path);
|
||||
println!("Headers: {:?}", headers);
|
||||
println!("Query params: {}", query_params);
|
||||
|
||||
// 返回响应
|
||||
HttpResponse::Ok().body("Hello, World!")
|
||||
}
|
||||
|
||||
#[actix_web::main]
|
||||
async fn main() -> io::Result<()> {
|
||||
// 设置 TCP backlog 大小为 5
|
||||
let backlog_size = 5;
|
||||
|
||||
HttpServer::new(|| App::new().route("/", web::get().to(index)))
|
||||
.backlog(backlog_size) // 设置 TCP backlog 大小
|
||||
.bind("0.0.0.0:12580")?
|
||||
.run()
|
||||
.await
|
||||
}
|
26
user/dadk/config/test_backlog_0_1_0.dadk
Normal file
26
user/dadk/config/test_backlog_0_1_0.dadk
Normal file
@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "test-backlog",
|
||||
"version": "0.1.0",
|
||||
"description": "test the tcp backlog",
|
||||
"rust_target": null,
|
||||
"task_type": {
|
||||
"BuildFromSource": {
|
||||
"Local": {
|
||||
"path": "apps/test-backlog"
|
||||
}
|
||||
}
|
||||
},
|
||||
"depends": [],
|
||||
"build": {
|
||||
"build_command": "make install"
|
||||
},
|
||||
"install": {
|
||||
"in_dragonos_path": "/"
|
||||
},
|
||||
"clean": {
|
||||
"clean_command": "make clean"
|
||||
},
|
||||
"envs": [],
|
||||
"build_once": false,
|
||||
"install_once": false
|
||||
}
|
Reference in New Issue
Block a user