- case SERVICE_CONTROL_STOP:
- logger(LOG_NOTICE, _("Got %s request"), "SERVICE_CONTROL_STOP");
- running = false;
- break;
- case SERVICE_CONTROL_SHUTDOWN:
- logger(LOG_NOTICE, _("Got %s request"), "SERVICE_CONTROL_SHUTDOWN");
- running = false;
- break;
- default:
- logger(LOG_WARNING, _("Got unexpected request %d"), request);
- return ERROR_CALL_NOT_IMPLEMENTED;
- }
-
- return NO_ERROR;
+ case SERVICE_CONTROL_INTERROGATE:
+ SetServiceStatus(statushandle, &status);
+ return NO_ERROR;
+
+ case SERVICE_CONTROL_STOP:
+ logger(LOG_NOTICE, "Got %s request", "SERVICE_CONTROL_STOP");
+ break;
+
+ case SERVICE_CONTROL_SHUTDOWN:
+ logger(LOG_NOTICE, "Got %s request", "SERVICE_CONTROL_SHUTDOWN");
+ break;
+
+ default:
+ logger(LOG_WARNING, "Got unexpected request %d", (int)request);
+ return ERROR_CALL_NOT_IMPLEMENTED;
+ }
+
+ if(running) {
+ running = false;
+ status.dwWaitHint = 30000;
+ status.dwCurrentState = SERVICE_STOP_PENDING;
+ SetServiceStatus(statushandle, &status);
+ return NO_ERROR;
+ } else {
+ status.dwWaitHint = 0;
+ status.dwCurrentState = SERVICE_STOPPED;
+ SetServiceStatus(statushandle, &status);
+ exit(1);
+ }
+