summaryrefslogtreecommitdiffstats
path: root/src/service-dbus
diff options
context:
space:
mode:
authorVitezslav Crhonek <vcrhonek@redhat.com>2013-09-10 14:56:15 +0200
committerVitezslav Crhonek <vcrhonek@redhat.com>2013-09-10 14:56:15 +0200
commit0097b6401cd129ba818d724e2c5f8625d2437260 (patch)
treef5ba6b128a65875c2c1e6172b064286cf472428c /src/service-dbus
parent791b011570fff533b6a178dc9be0b8f3d2d8a5e7 (diff)
downloadopenlmi-providers-0097b6401cd129ba818d724e2c5f8625d2437260.tar.gz
openlmi-providers-0097b6401cd129ba818d724e2c5f8625d2437260.tar.xz
openlmi-providers-0097b6401cd129ba818d724e2c5f8625d2437260.zip
Service: Fix detection of service state
Diffstat (limited to 'src/service-dbus')
-rw-r--r--src/service-dbus/util/serviceutil.c24
-rw-r--r--src/service-dbus/util/serviceutil.h1
2 files changed, 8 insertions, 17 deletions
diff --git a/src/service-dbus/util/serviceutil.c b/src/service-dbus/util/serviceutil.c
index b4b6d0c..af1e7ff 100644
--- a/src/service-dbus/util/serviceutil.c
+++ b/src/service-dbus/util/serviceutil.c
@@ -128,7 +128,6 @@ int service_get_properties(
GError *error = NULL;
gchar *fragment_path = NULL, *unit_file_state = NULL;
gchar *unit, *value_str;
- unsigned long value_long;
#if !defined(GLIB_VERSION_2_36)
g_type_init();
@@ -183,15 +182,6 @@ int service_get_properties(
if (!svc->svCaption) goto error;
error = NULL;
- result = g_dbus_proxy_call_sync(proxy, "Get", g_variant_new("(ss)", SERVICE_INTERFACE, "MainPID"),
- G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
- if (error) goto error;
-
- g_variant_get(result, "(v)", &result2);
- g_variant_get(result2, "u", &value_long);
- svc->pid = value_long;
-
- error = NULL;
result = g_dbus_proxy_call_sync(proxy, "Get", g_variant_new("(ss)", UNIT_INTERFACE, "ActiveState"),
G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
if (error) goto error;
@@ -202,32 +192,34 @@ int service_get_properties(
if (!strcmp(value_str, "active")) {
svc->svOperationalStatus[0] = OS_OK;
svc->svOperationalStatusCnt = 1;
+ svc->svStarted = 1;
+ svc->svStatus = strdup("OK");
}
else if (!strcmp(value_str, "inactive")) {
svc->svOperationalStatus[0] = OS_COMPLETED;
svc->svOperationalStatus[1] = OS_OK;
svc->svOperationalStatusCnt = 2;
+ svc->svStarted = 0;
+ svc->svStatus = strdup("Stopped");
}
else if (!strcmp(value_str, "failed")) {
svc->svOperationalStatus[0] = OS_COMPLETED;
svc->svOperationalStatus[1] = OS_ERROR;
svc->svOperationalStatusCnt = 2;
+ svc->svStarted = 0;
+ svc->svStatus = strdup("Stopped");
}
else if (!strcmp(value_str, "activating")) {
svc->svOperationalStatus[0] = OS_STARTING;
svc->svOperationalStatusCnt = 1;
+ svc->svStarted = 0;
+ svc->svStatus = strdup("Stopped");
}
else if (!strcmp(value_str, "deactivating")) {
svc->svOperationalStatus[0] = OS_STOPPING;
svc->svOperationalStatusCnt = 1;
- }
-
- if (svc->pid) {
svc->svStarted = 1;
svc->svStatus = strdup("OK");
- } else {
- svc->svStarted = 0;
- svc->svStatus = strdup("Stopped");
}
if (!svc->svStatus) goto error;
diff --git a/src/service-dbus/util/serviceutil.h b/src/service-dbus/util/serviceutil.h
index d3dcc33..d1ed1be 100644
--- a/src/service-dbus/util/serviceutil.h
+++ b/src/service-dbus/util/serviceutil.h
@@ -40,7 +40,6 @@ struct _Service {
char *svStatus; /* "Stopped", "OK" - deprecated, but recommended to fill */
enum ServiceEnabledDefault svEnabledDefault;
int svStarted; /* 0, 1 */
- int pid; /* PID */
};
struct _SList {