diff --git a/Cargo.lock b/Cargo.lock index cfff967..ea637bb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1438,7 +1438,7 @@ dependencies = [ [[package]] name = "simple-analytics" -version = "0.1.0" +version = "0.1.1" dependencies = [ "anyhow", "async-std", diff --git a/Cargo.toml b/Cargo.toml index 581ff8e..fc3add9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "simple-analytics" -version = "0.1.0" +version = "0.1.1" edition = "2021" [dependencies] diff --git a/src/submit.rs b/src/submit.rs index f0d7363..07076aa 100644 --- a/src/submit.rs +++ b/src/submit.rs @@ -13,7 +13,12 @@ pub async fn submit_event(mut req: Request) -> tide::Result { { let state = req.state().clone(); - let connection = state.0.lock().expect("failed to get read lock"); + let connection = if let Ok(v) = state.0.lock() { + v + } else { + error!("database mutex is poisoned. Restarting is probably required!"); + panic!("database mutex is poisoned"); + }; if let Err(err) = connection.execute( "INSERT INTO analytics (id, event_name, data) VALUES (?1, ?2, ?3)",