mullvad / windows-service-rs

Windows services in Rust
Apache License 2.0
525 stars 85 forks source link

Breaking: change `Service.delete` to borrow rather than consume `self` #90

Closed citreae535 closed 1 year ago

citreae535 commented 1 year ago

The underlying win32 API call merely marks the service for deletion. It can be called even if the service is not stopped and will not invalidate the caller's open handle to it. Making the function not consuming self allows the caller to decide when to close the handle. Docs and examples are updated to show the correct behavior of this API.


This change is Reviewable

citreae535 commented 1 year ago

Those println! are changed because this clippy lint, uninlined_format_args, shows up as warnings by default in 1.67.0. It was changed to allow in 1.67.1 but the maintainers said they "should restore this when rust-analyzer support gets better". As long as it is consistent I don't really have a strong opinion on this. Might be a good idea adding a clippy.toml if the old way is preferable.

citreae535 commented 1 year ago

This one can wait for #89 to make use of that error helper function in the example.

citreae535 commented 1 year ago

Just rebased it. Should be ready to merge.

pronebird commented 1 year ago

We had a call to thread::sleep() in uninstall example to let the service stop. Do you think we should keep it to be on the safe side? Feels like there can be a race between the call to stop the service and service_manager.open_service().

pronebird commented 1 year ago

@citreae535 previous PRs are already merged so you could perhaps rebase this one and see my other comment above too.

citreae535 commented 1 year ago

The uninstall example now polls for service stop and deletion with a timeout.

pronebird commented 1 year ago

Merged. Good work & thanks for contributions! 👍