operations.
"pinStart" and "pinStop" set the pin for the started and stopped
states respectively, but do not attempt to move the service into
the chosen state.
bool already_there = false;
switch (pktType) {
case DINIT_CP_STARTSERVICE:
- if (do_pin) {
- service->pinStart();
- }
- else {
- service->start();
- }
+ if (do_pin) service->pinStart();
+ service->start();
already_there = service->getState() == ServiceState::STARTED;
break;
case DINIT_CP_STOPSERVICE:
- if (do_pin) {
- service->pinStop();
- }
- else {
- service->stop();
- }
+ if (do_pin) service->pinStop();
+ service->stop();
already_there = service->getState() == ServiceState::STOPPED;
break;
case DINIT_CP_WAKESERVICE:
// re-start a stopped service.
- // TODO pinning
+ if (do_pin) service->pinStart();
service->start(false);
already_there = service->getState() == ServiceState::STARTED;
break;
}
}
-void ServiceRecord::pinStart() noexcept
-{
- start(true);
- pinned_started = true;
-}
-
-void ServiceRecord::pinStop() noexcept
-{
- stop();
- pinned_stopped = true;
-}
-
void ServiceRecord::unpin() noexcept
{
if (pinned_started) {
void forceStop() noexcept; // force-stop this service and all dependents
- void pinStart() noexcept; // start the service and pin it
- void pinStop() noexcept; // stop the service and pin it
- void unpin() noexcept; // unpin the service
+ // Pin the service in "started" state (when it reaches the state)
+ void pinStart() noexcept
+ {
+ pinned_started = true;
+ }
+
+ // Pin the service in "stopped" state (when it reaches the state)
+ void pinStop() noexcept
+ {
+ pinned_stopped = true;
+ }
+
+ // Remove both "started" and "stopped" pins. If the service is currently pinned
+ // in either state but would naturally be in the opposite state, it will immediately
+ // commence starting/stopping.
+ void unpin() noexcept;
bool isDummy() noexcept
{