MCPcopy Create free account
hub / github.com/PowerShell/DSC / wait_for_status

Function wait_for_status

resources/windows_service/src/service.rs:864–883  ·  view source on GitHub ↗

Wait for a service to reach the desired status, with a timeout.

(
    service_handle: SC_HANDLE,
    desired: &ServiceStatus,
)

Source from the content-addressed store, hash-verified

862
863/// Wait for a service to reach the desired status, with a timeout.
864unsafe fn wait_for_status(
865 service_handle: SC_HANDLE,
866 desired: &ServiceStatus,
867) -> Result<(), ServiceError> {
868 let start = std::time::Instant::now();
869 let timeout = std::time::Duration::from_secs(STATUS_WAIT_TIMEOUT_SECS);
870 loop {
871 let current = unsafe { query_status(service_handle)? };
872 if current == *desired {
873 return Ok(());
874 }
875 if start.elapsed() > timeout {
876 return Err(t!("set.statusTimeout",
877 expected = desired.to_string(),
878 actual = current.to_string()
879 ).to_string().into());
880 }
881 std::thread::sleep(std::time::Duration::from_millis(STATUS_POLL_INTERVAL_MS));
882 }
883}
884
885/// Check whether `service` matches all non-`None` fields in `filter`.
886fn matches_filter(service: &WindowsService, filter: &WindowsService) -> bool {

Callers 1

set_serviceFunction · 0.85

Calls 1

query_statusFunction · 0.85

Tested by

no test coverage detected