mirror of
https://git.proxmox.com/git/proxmox
synced 2025-05-30 00:28:13 +00:00
implement relead_timezone flag
This commit is contained in:
parent
5d63509787
commit
9707fdadd7
@ -27,6 +27,8 @@ use hyper::service::{Service, NewService};
|
|||||||
use hyper::rt::{Future, Stream};
|
use hyper::rt::{Future, Stream};
|
||||||
use hyper::header;
|
use hyper::header;
|
||||||
|
|
||||||
|
extern "C" { fn tzset(); }
|
||||||
|
|
||||||
pub struct RestServer {
|
pub struct RestServer {
|
||||||
pub api_config: Arc<ApiConfig>,
|
pub api_config: Arc<ApiConfig>,
|
||||||
}
|
}
|
||||||
@ -135,6 +137,7 @@ fn get_request_parameters_async(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn proxy_protected_request(
|
fn proxy_protected_request(
|
||||||
|
info: &'static ApiMethod,
|
||||||
mut parts: Parts,
|
mut parts: Parts,
|
||||||
req_body: Body,
|
req_body: Body,
|
||||||
) -> BoxFut
|
) -> BoxFut
|
||||||
@ -154,6 +157,12 @@ fn proxy_protected_request(
|
|||||||
.request(request)
|
.request(request)
|
||||||
.map_err(|e| Error::from(e));
|
.map_err(|e| Error::from(e));
|
||||||
|
|
||||||
|
let resp = if info.reload_timezone {
|
||||||
|
Either::A(resp.then(|resp| {unsafe { tzset() }; resp }))
|
||||||
|
} else {
|
||||||
|
Either::B(resp)
|
||||||
|
};
|
||||||
|
|
||||||
return Box::new(resp);
|
return Box::new(resp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,6 +192,10 @@ fn handle_sync_api_request(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if info.reload_timezone {
|
||||||
|
unsafe { tzset() };
|
||||||
|
}
|
||||||
|
|
||||||
if delay {
|
if delay {
|
||||||
let delayed_response = tokio::timer::Delay::new(delay_unauth_time)
|
let delayed_response = tokio::timer::Delay::new(delay_unauth_time)
|
||||||
.map_err(|err| http_err!(INTERNAL_SERVER_ERROR, format!("tokio timer delay error: {}", err)))
|
.map_err(|err| http_err!(INTERNAL_SERVER_ERROR, format!("tokio timer delay error: {}", err)))
|
||||||
@ -462,7 +475,7 @@ pub fn handle_request(api: Arc<ApiConfig>, req: Request<Body>) -> BoxFut {
|
|||||||
MethodDefinition::None => {}
|
MethodDefinition::None => {}
|
||||||
MethodDefinition::Simple(api_method) => {
|
MethodDefinition::Simple(api_method) => {
|
||||||
if api_method.protected && env_type == RpcEnvironmentType::PUBLIC {
|
if api_method.protected && env_type == RpcEnvironmentType::PUBLIC {
|
||||||
return proxy_protected_request(parts, body);
|
return proxy_protected_request(api_method, parts, body);
|
||||||
} else {
|
} else {
|
||||||
return handle_sync_api_request(rpcenv, api_method, formatter, parts, body, uri_param);
|
return handle_sync_api_request(rpcenv, api_method, formatter, parts, body, uri_param);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user