fix: WHIP not cleaning up

This commit is contained in:
2026-08-07 17:21:15 +01:00
parent e00541c07d
commit aa1d4e8f67
3 changed files with 14 additions and 9 deletions
Generated
+1 -1
View File
@@ -2906,7 +2906,7 @@ dependencies = [
[[package]]
name = "server"
version = "0.3.0"
version = "0.4.0"
dependencies = [
"argon2",
"async-broadcast",
-1
View File
@@ -201,7 +201,6 @@ async fn catalog_handler(
user: x.stream_key_user.clone(),
started_at: x.started_at,
})
.into_iter()
.collect::<Vec<_>>();
Ok(Json(catalog))
}
+13 -7
View File
@@ -28,6 +28,7 @@ use crate::{
pub async fn handle_whip_injest_delete(
State(state): State<Arc<HttpServer>>,
ConnectInfo(remote): ConnectInfo<SocketAddr>,
Path(_slug): Path<String>,
headers: HeaderMap,
) -> Result<impl IntoResponse, HttpError> {
let token = headers
@@ -44,14 +45,19 @@ pub async fn handle_whip_injest_delete(
.await?
.ok_or(HttpError::Unauthorized)?;
let active_session = stream_session::Model::get_active_by_stream_key_id(&state.db, key.id)
.await?
.ok_or(HttpError::NotFound)?;
// The detach task may have already cleaned up the session when ICE
// disconnected (OBS closes the PeerConnection before sending DELETE).
// Deleting an already-gone session is still a successful delete.
if let Some(active_session) =
stream_session::Model::get_active_by_stream_key_id(&state.db, key.id).await?
{
active_session
.into_active_model()
.finish_stream_session(&state.db, Utc::now())
.await?;
}
active_session
.into_active_model()
.finish_stream_session(&state.db, Utc::now())
.await?;
state.appstate.lock().await.stream_sessions.remove(&key.id);
Ok(StatusCode::OK)
}