Skip to content

Commit

Permalink
Fix a few more comments
Browse files Browse the repository at this point in the history
  • Loading branch information
MolotovCherry committed Sep 18, 2024
1 parent 662a330 commit bd9cc34
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions pueue/src/daemon/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,9 @@ fn service_event_loop() -> Result<()> {
reason: SessionChangeReason::SessionLogoff,
..
}) => {
// Windows services kill all user processes on logoff.
// So this stopping is basically a noop, but I favor explicitness.
// See module-level docs for more details.
debug!("event logoff");
spawner.stop();

Expand Down Expand Up @@ -294,7 +297,7 @@ fn service_event_loop() -> Result<()> {

set_status(ServiceState::StartPending, ServiceControlAccept::empty())?;

// make sure we have privileges - this should always succeed
// Make sure we have privileges - this should always succeed
if let Err(e) = set_privilege(SE_TCB_NAME, true) {
set_status(ServiceState::Stopped, ServiceControlAccept::empty())?;
bail!("failed to set privileges: {e}");
Expand Down Expand Up @@ -326,7 +329,7 @@ fn service_event_loop() -> Result<()> {
Ok(())
}

/// set the specified process privilege to state
/// Set the specified process privilege to state.
/// https://learn.microsoft.com/en-us/windows/win32/secauthz/privilege-constants
fn set_privilege(name: PCWSTR, state: bool) -> Result<()> {
let handle: OwnedHandle =
Expand Down Expand Up @@ -597,8 +600,8 @@ impl Spawner {
.chain(iter::once(0))
.collect::<Vec<_>>();

// lpcommandline may modify the the cmd vec. max valid size is 1024, so
// I think it best to ensure 1024 bytes of capacity total exist just in case
// lpcommandline may modify the the cmd vec. Max valid size is 1024, so
// I think it best to ensure 1024 bytes of capacity total exist just in case.
command.reserve(1024 - (command.len() / 2));

let env_block = EnvBlock::new(token.0)?;
Expand Down Expand Up @@ -635,7 +638,7 @@ impl Spawner {

running.store(false, Ordering::Relaxed);

// check if process exited on its own without our explicit request
// Check if process exited on its own without our explicit request.
if !request_stop.swap(false, Ordering::Relaxed) {
let mut code = 0u32;
unsafe {
Expand Down

0 comments on commit bd9cc34

Please sign in to comment.