diff options
author | David Härdeman <david@hardeman.nu> | 2020-06-10 19:01:39 +0200 |
---|---|---|
committer | David Härdeman <david@hardeman.nu> | 2020-06-10 19:01:39 +0200 |
commit | 320f600cd980230b2b2e34c7256c9564af6afae9 (patch) | |
tree | fd64b3545a386255ddccb71d3f97dd141b0d14a9 /systemd.c | |
parent | af7dbbcbc9fe89deb4951d45b0f6ce839199c88b (diff) |
Add some basic memory tracking infrastructure while hacking
Diffstat (limited to 'systemd.c')
-rw-r--r-- | systemd.c | 104 |
1 files changed, 2 insertions, 102 deletions
@@ -41,7 +41,7 @@ systemd_service_object_path(struct cfg *cfg, const char *service) return NULL; } - r = malloc(strlen(SYSTEMD_DBUS_PATH_PREFIX) + strlen(service) * 3 + 1); + r = zmalloc(strlen(SYSTEMD_DBUS_PATH_PREFIX) + strlen(service) * 3 + 1); if (!r) return NULL; @@ -140,7 +140,7 @@ systemd_service_running(struct cfg *cfg, struct server *server) server->systemd_service, server->systemd_obj); out: - free(status); + xfree(status); sd_bus_error_free(&error); return running; } @@ -219,103 +219,3 @@ systemd_service_start(struct cfg *cfg, struct server *server) return systemd_service_action(cfg, server, "Start"); } - -#if 0 - - - - -int main(int argc, char *argv[]) { - sd_bus_error error = SD_BUS_ERROR_NULL; - sd_bus_message *m = NULL; - sd_bus *bus = NULL; - const char *path; - int r; - - /* Connect to the system bus */ - r = sd_bus_open_user(&bus); - if (r < 0) { - fprintf(stderr, "Failed to connect to system bus: %s\n", strerror(-r)); - goto finish; - } - - /* Issue the method call and store the respons message in m */ - r = sd_bus_call_method(bus, - "org.freedesktop.systemd1", /* service to contact */ - "/org/freedesktop/systemd1", /* object path */ - "org.freedesktop.systemd1.Manager", /* interface name */ - "StartUnit", /* method name */ - &error, /* object to return error in */ - &m, /* return message on success */ - "ss", /* input signature */ - "apa.service", /* first argument */ - "fail"); /* second argument */ - if (r < 0) { - fprintf(stderr, "Failed to issue method call: %s\n", error.message); - goto finish; - } - - /* Parse the response message */ - r = sd_bus_message_read(m, "o", &path); - if (r < 0) { - fprintf(stderr, "Failed to parse response message: %s\n", strerror(-r)); - goto finish; - } - printf("Queued service job as %s.\n", path); - - sd_bus_error_free(&error); - sd_bus_message_unref(m); - error = SD_BUS_ERROR_NULL; - m = NULL; - - /* - gdbus call --session - --dest org.freedesktop.systemd1 - --object-path /org/freedesktop/systemd1/unit/myapa_40local2_2eservice - --method org.freedesktop.systemd1.Unit.Start "fail" - - gdbus introspect --session - --dest org.freedesktop.systemd1 - --object-path /org/freedesktop/systemd1/unit/myapa_40local_2eservice - - gdbus call --session - --dest org.freedesktop.systemd1 - --object-path /org/freedesktop/systemd1/unit/myapa_40basker_2eservice - --method org.freedesktop.DBus.Properties.Get - "org.freedesktop.systemd1.Unit" - "ActiveState" - */ - char *res; - r = sd_bus_get_property_string(bus, - "org.freedesktop.systemd1", - "/org/freedesktop/systemd1/unit/apa_2eservice", - "org.freedesktop.systemd1.Unit", - "ActiveState", - &error, - &res); - if (r < 0) { - fprintf(stderr, "Failed to issue prop call: %s\n", error.message); - goto finish; - } - - fprintf(stderr, "RESULT: %s\n", res); -/* - int sd_bus_get_property_string(sd_bus *bus, - const char *destination, - const char *path, - const char *interface, - const char *member, - sd_bus_error *ret_error, - char **ret); - */ -/* -finish: - sd_bus_error_free(&error); - sd_bus_message_unref(m); - sd_bus_unref(bus); - */ - -finish: - return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; -} -#endif |