Skip to content

Commit

Permalink
Merge pull request #21 from pi-hole/fix/clients-over-time-lock-bug
Browse files Browse the repository at this point in the history
Fix deadlock caused by concurrent FTL API accesses
  • Loading branch information
AzureMarker committed Jun 11, 2018
2 parents 05e1640 + cd8acff commit f6a9958
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/stats/over_time_clients.rs
Expand Up @@ -19,11 +19,13 @@ use stats::clients::get_clients;
/// Get the client queries over time
#[get("/stats/overTime/clients")]
pub fn over_time_clients(_auth: User, ftl: State<FtlConnectionType>) -> util::Reply {
let mut con = ftl.connect("ClientsoverTime")?;

let mut over_time = Vec::new();
let clients = get_clients(&ftl)?;

// Don't open another FTL connection until the connection from `get_clients` is done!
// Otherwise FTL's global lock mechanism will cause a deadlock.
let mut con = ftl.connect("ClientsoverTime")?;

loop {
// Get the timestamp, unless we are at the end of the list
let timestamp = match con.read_i32() {
Expand Down

0 comments on commit f6a9958

Please sign in to comment.