Skip to content

Commit 173d686

Browse files
Inject RES_OPTIONS to cap glibc resolver DNS timeouts (#45)
1 parent dc47b2a commit 173d686

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/main.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,17 @@ async fn main() -> Result<()> {
517517
}
518518
}
519519

520+
// Inject glibc resolver timeouts to avoid long DNS hangs if not already set
521+
if std::env::var("RES_OPTIONS").is_err() && !extra_env.iter().any(|(k, _)| k == "RES_OPTIONS") {
522+
debug!("Setting glibc resolver timeouts via RES_OPTIONS=timeout:2 attempts:1");
523+
extra_env.push((
524+
"RES_OPTIONS".to_string(),
525+
"timeout:2 attempts:1".to_string(),
526+
));
527+
} else {
528+
debug!("RES_OPTIONS already present; not overriding existing setting");
529+
}
530+
520531
// Execute command in jail with extra environment variables
521532
let status = if let Some(timeout_secs) = args.timeout {
522533
info!("Executing command with {}s timeout", timeout_secs);

0 commit comments

Comments
 (0)