actix / actix/actix-web

Sockets and pipes open after stopping server/system

Abierto
#1,787 3 comentarios 0 reacciones 0 asignados Ver en GitHub
A-web needs-investigation
Lenguaje dominante
Rust
Estrellas
24.8k
Forks
1.9k
Merge medio
23 h 10 min
PR fusionados (30 d)
26

Descripción

## Expected Behavior
Stopping server/system closes all sockets and pipes.

## Current Behavior
Stopping the server/system (without exiting the process) leaves a number of sockets and pipes open.
Therefore, restarting the server increases the number of open sockets and pipes.

## Steps to Reproduce
```
use actix_web::{middleware, App, HttpServer};

pub fn main() -> std::io::Result<()> {
// - inside loop: each iteration opens 22 new pipes, 0 new sockets
// - outside loop: each iteration opens 2 new pipes, 4 new sockets
let mut system = actix_web::rt::System::new("main");

loop {
system.block_on::<_, std::io::Result<()>>(async move {
HttpServer::new(move || App::new().wrap(middleware::Logger::default()))
.bind("127.0.0.1:8080")?
.run()
.await
})?;

// doesn't stop everything...? see https://github.com/actix/actix-web/issues/1249
actix_web::rt::System::current().stop();
}
}
```
`ls -l /proc/[PID]/fd` contains 7 sockets and 28 pipes in the first iteration. Pressing `Ctrl+C` shuts down the server (and the system) and proceeds to the next iteration. This time `ls -l /proc/[PID]/fd` contains 11 sockets and 30 pipes.

Moving `let mut system = ...` into the loop avoids increasing the number of open sockets, but at the same time increases the number of open pipes by 22 in each iteration.

## Context
I am trying to restart the server to change routes/handlers. Since the router is read-only, restarting the server is the only solution that does not involve writing a custom router.

Besides the issue reported here, a simple solution based on https://github.com/actix/examples/tree/master/shutdown-server (slightly extended to differentiate stop/restart) works well.

## Your Environment
* Linux
* Rust Version: 1.46.0
* Actix Web Version: 3.2

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.