Predicting_real_estate_prices_using_scikit-learn icon indicating copy to clipboard operation
Predicting_real_estate_prices_using_scikit-learn copied to clipboard

[SERVICES.EXE] Attempt to fix the service stop sequence

Open yagoulas opened this issue 6 years ago • 5 comments

ScmReferenceService, ScmDereferenceService :Add two helpers that implement reference counting for services. A reference will prevent a service from being deleted. Releasing the last reference will handle deleting the service if needed. A running service will hold one reference and a service handle will hold another one. Holding a reference means that a PSERVICE pointer will be valid as long as the reference is held.

RSetServiceStatus: When stopping a service don't release the reference immediately, let a worker thread release it after SERVICE_CONTROL_STOP is sent.

This effectively means that trying to delete a running service will make it really get deleted when the service stops (and all handles get closed).

This was based on commit f6d81f2 which was reverted in 1820aa8.

This fixes the deadlock that can be triggered when the spooler service gets stopped. CORE-15064

TODO

  • [x] The code in RSetServiceStatus where we access lpService after releasing the reference is probably wrong as lpService could be freed at any time.
  • [ ] Perhaps assertions need to be added so that we are always sure that ScmControlService is never called with the database lock being held and that ScmDereferenceService is never called without the database lock.

yagoulas avatar Jan 07 '19 11:01 yagoulas