feat: Add parallel HTTP server E2E tests and enhance plugin system
- Add e2e_plugin_net_additional.rs with parallel server tests - Fix test to properly handle request objects (no double accept) - Add comprehensive net-plugin documentation - Implement debug tracing for method calls - Enhance plugin lifecycle documentation - Improve error handling in plugin loader - Add leak tracking infrastructure (for future use) - Update language spec with latest plugin features This enhances test coverage for concurrent HTTP servers and improves the overall plugin system documentation and debugging capabilities. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
38
src/debug/leak_tracker.rs
Normal file
38
src/debug/leak_tracker.rs
Normal file
@ -0,0 +1,38 @@
|
||||
use once_cell::sync::Lazy;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Mutex;
|
||||
|
||||
static ENABLED: Lazy<bool> = Lazy::new(|| std::env::var("NYASH_LEAK_LOG").unwrap_or_default() == "1");
|
||||
static LEAKS: Lazy<Mutex<HashMap<(String, u32), &'static str>>> = Lazy::new(|| Mutex::new(HashMap::new()));
|
||||
|
||||
pub fn init() {
|
||||
let _ = &*REPORTER; // ensure reporter is constructed
|
||||
}
|
||||
|
||||
pub fn register_plugin(box_type: &str, instance_id: u32) {
|
||||
if !*ENABLED { return; }
|
||||
let mut m = LEAKS.lock().unwrap();
|
||||
m.insert((box_type.to_string(), instance_id), "plugin");
|
||||
}
|
||||
|
||||
pub fn finalize_plugin(box_type: &str, instance_id: u32) {
|
||||
if !*ENABLED { return; }
|
||||
let mut m = LEAKS.lock().unwrap();
|
||||
m.remove(&(box_type.to_string(), instance_id));
|
||||
}
|
||||
|
||||
struct Reporter;
|
||||
impl Drop for Reporter {
|
||||
fn drop(&mut self) {
|
||||
if !*ENABLED { return; }
|
||||
let m = LEAKS.lock().unwrap();
|
||||
if m.is_empty() { return; }
|
||||
eprintln!("[leak] Detected {} non-finalized plugin boxes:", m.len());
|
||||
for ((ty, id), _) in m.iter() {
|
||||
eprintln!(" - {}(id={}) not finalized (missing fini or scope)", ty, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static REPORTER: Lazy<Reporter> = Lazy::new(|| Reporter);
|
||||
|
||||
Reference in New Issue
Block a user