Skip to content

Commit

Permalink
a
Browse files Browse the repository at this point in the history
Signed-off-by: Calvin Neo <[email protected]>
  • Loading branch information
CalvinNeo committed Aug 28, 2024
1 parent 9aa9d0e commit 99a64a5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
20 changes: 14 additions & 6 deletions proxy_components/proxy_server/src/status_server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ use tokio::{
};
use tokio_openssl::SslStream;

use crate::status_server::profile::set_prof_active;

static TIMER_CANCELED: &str = "tokio timer canceled";

#[cfg(feature = "failpoints")]
Expand Down Expand Up @@ -206,7 +208,7 @@ where
None => 60,
};

let enable_period = match query_pairs.get("period") {
let enable_period: u64 = match query_pairs.get("period") {
Some(val) => match val.parse() {
Ok(val) => val,
Err(err) => return Ok(make_response(StatusCode::BAD_REQUEST, err.to_string())),
Expand All @@ -216,7 +218,7 @@ where

if enable_period == 0 {
let msg = "set prof.active = true";
set_prof_active(true);
let _ = set_prof_active(true);
return Ok(make_response(StatusCode::OK, msg));
}

Expand All @@ -239,13 +241,16 @@ where
}
}

fn deactivate_heap_prof(_req: Request<Body>) -> hyper::Result<Response<Body>> {
let disable_period = match query_pairs.get("period") {
fn deactivate_heap_prof(req: Request<Body>) -> hyper::Result<Response<Body>> {
let query = req.uri().query().unwrap_or("");
let query_pairs: HashMap<_, _> = url::form_urlencoded::parse(query.as_bytes()).collect();

let disable_period: u64 = match query_pairs.get("period") {
Some(val) => match val.parse() {
Ok(val) => val,
Err(err) => return Ok(make_response(StatusCode::BAD_REQUEST, err.to_string())),
},
None => 1,
None => 0,
};

let body = if deactivate_heap_profile() {
Expand All @@ -254,8 +259,11 @@ where
"no heap profile is running"
};

// If we only disable period dump.
if disable_period == 1 {
set_prof_active(false);
let _ = set_prof_active(true);
} else {
let _ = set_prof_active(false);
}

Ok(make_response(StatusCode::OK, body))
Expand Down
1 change: 1 addition & 0 deletions proxy_components/proxy_server/src/status_server/profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use tokio::sync::{Mutex, MutexGuard};
pub use self::test_utils::TEST_PROFILE_MUTEX;
#[cfg(test)]
use self::test_utils::{activate_prof, deactivate_prof, dump_prof};
use super::vendored_utils::has_activate_prof;
#[cfg(not(test))]
use super::vendored_utils::{activate_prof, deactivate_prof, dump_prof};

Expand Down

0 comments on commit 99a64a5

Please sign in to comment.