Skip to content

Commit

Permalink
daemon-windows: Rename service variables.
Browse files Browse the repository at this point in the history
Sa far, we are using variable 'detach' to indicate whether the option
"--service" has been set. We were using variable 'detached' to indicate that
the daemon is being called from the Windows services manager.

An upcoming commit introduces command line option "--detach" for daemons
running on Windows. This will cause confusion with variable names.
Therefore, rename the variables.

Signed-off-by: Gurucharan Shetty <[email protected]>
Acked-by: Ben Pfaff <[email protected]>
  • Loading branch information
shettyg committed Apr 22, 2014
1 parent e3f512b commit 69b1783
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lib/daemon-windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

VLOG_DEFINE_THIS_MODULE(daemon);

static bool detach; /* Was --service specified? */
static bool detached; /* Have we already detached? */
static bool service_create; /* Was --service specified? */
static bool service_started; /* Have we dispatched service to start? */

/* --service-monitor: Should the service be restarted if it dies
* unexpectedly? */
Expand Down Expand Up @@ -77,10 +77,10 @@ service_start(int *argcp, char **argvp[])
{NULL, NULL}
};

/* 'detached' is 'false' when service_start() is called the first time.
* It is 'true', when it is called the second time by the Windows services
* manager. */
if (detached) {
/* 'service_started' is 'false' when service_start() is called the first
* time. It is 'true', when it is called the second time by the Windows
* services manager. */
if (service_started) {
init_service_status();

wevent = CreateEvent(NULL, TRUE, FALSE, NULL);
Expand Down Expand Up @@ -133,14 +133,14 @@ service_start(int *argcp, char **argvp[])
* options before the call-back from the service control manager. */
for (i = 0; i < argc; i ++) {
if (!strcmp(argv[i], "--service")) {
detach = true;
service_create = true;
} else if (!strcmp(argv[i], "--service-monitor")) {
monitor = true;
}
}

/* If '--service' is not a command line option, run in foreground. */
if (!detach) {
if (!service_create) {
return;
}

Expand All @@ -149,7 +149,7 @@ service_start(int *argcp, char **argvp[])
* script. */
check_service();

detached = true;
service_started = true;

/* StartServiceCtrlDispatcher blocks and returns after the service is
* stopped. */
Expand Down Expand Up @@ -184,7 +184,7 @@ control_handler(DWORD request)
bool
should_service_stop(void)
{
if (detached) {
if (service_started) {
if (service_status.dwCurrentState != SERVICE_RUNNING) {
return true;
} else {
Expand Down

0 comments on commit 69b1783

Please sign in to comment.