mirror of
https://github.com/systemd/systemd.git
synced 2024-12-26 03:22:00 +03:00
dbus-wait-for-jobs: change 'quiet' flag to enum
Change the 'quiet' flag to `bus_wait_for_jobs()` to an enum, so we can select with more granularity the type of information logged.
This commit is contained in:
parent
97e52d62fb
commit
e22ad53d5c
@ -1622,7 +1622,7 @@ static int reload_vconsole(sd_bus **bus) {
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
return bus_log_parse_error(r);
|
return bus_log_parse_error(r);
|
||||||
|
|
||||||
r = bus_wait_for_jobs_one(w, object, false, NULL);
|
r = bus_wait_for_jobs_one(w, object, BUS_WAIT_JOBS_LOG_ERROR, NULL);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to wait for systemd-vconsole-setup.service/restart: %m");
|
return log_error_errno(r, "Failed to wait for systemd-vconsole-setup.service/restart: %m");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -665,7 +665,7 @@ static int start_transient_mount(
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
return bus_log_parse_error(r);
|
return bus_log_parse_error(r);
|
||||||
|
|
||||||
r = bus_wait_for_jobs_one(w, object, arg_quiet, NULL);
|
r = bus_wait_for_jobs_one(w, object, arg_quiet ? 0 : BUS_WAIT_JOBS_LOG_ERROR, NULL);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
@ -774,7 +774,7 @@ static int start_transient_automount(
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
return bus_log_parse_error(r);
|
return bus_log_parse_error(r);
|
||||||
|
|
||||||
r = bus_wait_for_jobs_one(w, object, arg_quiet, NULL);
|
r = bus_wait_for_jobs_one(w, object, arg_quiet ? 0 : BUS_WAIT_JOBS_LOG_ERROR, NULL);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
@ -936,7 +936,7 @@ static int stop_mount(
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
return bus_log_parse_error(r);
|
return bus_log_parse_error(r);
|
||||||
|
|
||||||
r = bus_wait_for_jobs_one(w, object, arg_quiet, NULL);
|
r = bus_wait_for_jobs_one(w, object, arg_quiet ? 0 : BUS_WAIT_JOBS_LOG_ERROR, NULL);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -3163,7 +3163,7 @@ static int udevd_reload(sd_bus *bus) {
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
return bus_log_parse_error(r);
|
return bus_log_parse_error(r);
|
||||||
|
|
||||||
r = bus_wait_for_jobs_one(w, job_path, /* quiet = */ true, NULL);
|
r = bus_wait_for_jobs_one(w, job_path, /* flags = */ 0, NULL);
|
||||||
if (r == -ENOEXEC) {
|
if (r == -ENOEXEC) {
|
||||||
log_debug("systemd-udevd is not running, skipping reload.");
|
log_debug("systemd-udevd is not running, skipping reload.");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -368,7 +368,7 @@ int allocate_scope(
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
return bus_log_parse_error(r);
|
return bus_log_parse_error(r);
|
||||||
|
|
||||||
r = bus_wait_for_jobs_one(w, object, false, NULL);
|
r = bus_wait_for_jobs_one(w, object, BUS_WAIT_JOBS_LOG_ERROR, NULL);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
|
@ -1381,7 +1381,7 @@ static int start_transient_service(sd_bus *bus) {
|
|||||||
|
|
||||||
r = bus_wait_for_jobs_one(w,
|
r = bus_wait_for_jobs_one(w,
|
||||||
object,
|
object,
|
||||||
arg_quiet,
|
arg_quiet ? 0 : BUS_WAIT_JOBS_LOG_ERROR,
|
||||||
arg_runtime_scope == RUNTIME_SCOPE_USER ? STRV_MAKE_CONST("--user") : NULL);
|
arg_runtime_scope == RUNTIME_SCOPE_USER ? STRV_MAKE_CONST("--user") : NULL);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
@ -1616,7 +1616,8 @@ static int start_transient_scope(sd_bus *bus) {
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
return bus_log_parse_error(r);
|
return bus_log_parse_error(r);
|
||||||
|
|
||||||
r = bus_wait_for_jobs_one(w, object, arg_quiet, arg_runtime_scope == RUNTIME_SCOPE_USER ? STRV_MAKE_CONST("--user") : NULL);
|
r = bus_wait_for_jobs_one(w, object, arg_quiet ? 0 : BUS_WAIT_JOBS_LOG_ERROR,
|
||||||
|
arg_runtime_scope == RUNTIME_SCOPE_USER ? STRV_MAKE_CONST("--user") : NULL);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
@ -1886,7 +1887,8 @@ static int start_transient_trigger(sd_bus *bus, const char *suffix) {
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
return bus_log_parse_error(r);
|
return bus_log_parse_error(r);
|
||||||
|
|
||||||
r = bus_wait_for_jobs_one(w, object, arg_quiet, arg_runtime_scope == RUNTIME_SCOPE_USER ? STRV_MAKE_CONST("--user") : NULL);
|
r = bus_wait_for_jobs_one(w, object, arg_quiet ? 0 : BUS_WAIT_JOBS_LOG_ERROR,
|
||||||
|
arg_runtime_scope == RUNTIME_SCOPE_USER ? STRV_MAKE_CONST("--user") : NULL);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
|
@ -227,12 +227,12 @@ finish:
|
|||||||
service_shell_quoted ?: "<service>");
|
service_shell_quoted ?: "<service>");
|
||||||
}
|
}
|
||||||
|
|
||||||
static int check_wait_response(BusWaitForJobs *d, bool quiet, const char* const* extra_args) {
|
static int check_wait_response(BusWaitForJobs *d, WaitJobsFlags flags, const char* const* extra_args) {
|
||||||
assert(d);
|
assert(d);
|
||||||
assert(d->name);
|
assert(d->name);
|
||||||
assert(d->result);
|
assert(d->result);
|
||||||
|
|
||||||
if (!quiet) {
|
if (FLAGS_SET(flags, BUS_WAIT_JOBS_LOG_ERROR)) {
|
||||||
if (streq(d->result, "canceled"))
|
if (streq(d->result, "canceled"))
|
||||||
log_error("Job for %s canceled.", strna(d->name));
|
log_error("Job for %s canceled.", strna(d->name));
|
||||||
else if (streq(d->result, "timeout"))
|
else if (streq(d->result, "timeout"))
|
||||||
@ -286,7 +286,7 @@ static int check_wait_response(BusWaitForJobs *d, bool quiet, const char* const*
|
|||||||
"Unexpected job result, assuming server side newer than us: %s", d->result);
|
"Unexpected job result, assuming server side newer than us: %s", d->result);
|
||||||
}
|
}
|
||||||
|
|
||||||
int bus_wait_for_jobs(BusWaitForJobs *d, bool quiet, const char* const* extra_args) {
|
int bus_wait_for_jobs(BusWaitForJobs *d, WaitJobsFlags flags, const char* const* extra_args) {
|
||||||
int r = 0;
|
int r = 0;
|
||||||
|
|
||||||
assert(d);
|
assert(d);
|
||||||
@ -299,7 +299,7 @@ int bus_wait_for_jobs(BusWaitForJobs *d, bool quiet, const char* const* extra_ar
|
|||||||
return log_error_errno(q, "Failed to wait for response: %m");
|
return log_error_errno(q, "Failed to wait for response: %m");
|
||||||
|
|
||||||
if (d->name && d->result) {
|
if (d->name && d->result) {
|
||||||
q = check_wait_response(d, quiet, extra_args);
|
q = check_wait_response(d, flags, extra_args);
|
||||||
/* Return the first error as it is most likely to be
|
/* Return the first error as it is most likely to be
|
||||||
* meaningful. */
|
* meaningful. */
|
||||||
if (q < 0 && r == 0)
|
if (q < 0 && r == 0)
|
||||||
@ -322,12 +322,12 @@ int bus_wait_for_jobs_add(BusWaitForJobs *d, const char *path) {
|
|||||||
return set_put_strdup(&d->jobs, path);
|
return set_put_strdup(&d->jobs, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
int bus_wait_for_jobs_one(BusWaitForJobs *d, const char *path, bool quiet, const char* const* extra_args) {
|
int bus_wait_for_jobs_one(BusWaitForJobs *d, const char *path, WaitJobsFlags flags, const char* const* extra_args) {
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
r = bus_wait_for_jobs_add(d, path);
|
r = bus_wait_for_jobs_add(d, path);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_oom();
|
return log_oom();
|
||||||
|
|
||||||
return bus_wait_for_jobs(d, quiet, extra_args);
|
return bus_wait_for_jobs(d, flags, extra_args);
|
||||||
}
|
}
|
||||||
|
@ -5,12 +5,16 @@
|
|||||||
|
|
||||||
#include "macro.h"
|
#include "macro.h"
|
||||||
|
|
||||||
|
typedef enum WaitJobsFlags {
|
||||||
|
BUS_WAIT_JOBS_LOG_ERROR = 1 << 0,
|
||||||
|
} WaitJobsFlags;
|
||||||
|
|
||||||
typedef struct BusWaitForJobs BusWaitForJobs;
|
typedef struct BusWaitForJobs BusWaitForJobs;
|
||||||
|
|
||||||
int bus_wait_for_jobs_new(sd_bus *bus, BusWaitForJobs **ret);
|
int bus_wait_for_jobs_new(sd_bus *bus, BusWaitForJobs **ret);
|
||||||
BusWaitForJobs* bus_wait_for_jobs_free(BusWaitForJobs *d);
|
BusWaitForJobs* bus_wait_for_jobs_free(BusWaitForJobs *d);
|
||||||
int bus_wait_for_jobs_add(BusWaitForJobs *d, const char *path);
|
int bus_wait_for_jobs_add(BusWaitForJobs *d, const char *path);
|
||||||
int bus_wait_for_jobs(BusWaitForJobs *d, bool quiet, const char* const* extra_args);
|
int bus_wait_for_jobs(BusWaitForJobs *d, WaitJobsFlags flags, const char* const* extra_args);
|
||||||
int bus_wait_for_jobs_one(BusWaitForJobs *d, const char *path, bool quiet, const char* const* extra_args);
|
int bus_wait_for_jobs_one(BusWaitForJobs *d, const char *path, WaitJobsFlags flags, const char* const* extra_args);
|
||||||
|
|
||||||
DEFINE_TRIVIAL_CLEANUP_FUNC(BusWaitForJobs*, bus_wait_for_jobs_free);
|
DEFINE_TRIVIAL_CLEANUP_FUNC(BusWaitForJobs*, bus_wait_for_jobs_free);
|
||||||
|
@ -249,7 +249,7 @@ static int allocate_scope(void) {
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
return bus_log_parse_error(r);
|
return bus_log_parse_error(r);
|
||||||
|
|
||||||
r = bus_wait_for_jobs_one(w, object, false, NULL);
|
r = bus_wait_for_jobs_one(w, object, BUS_WAIT_JOBS_LOG_ERROR, NULL);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
|
@ -388,8 +388,10 @@ int verb_start(int argc, char *argv[], void *userdata) {
|
|||||||
|
|
||||||
if (!arg_no_block) {
|
if (!arg_no_block) {
|
||||||
const char* extra_args[4];
|
const char* extra_args[4];
|
||||||
|
WaitJobsFlags flags = 0;
|
||||||
|
|
||||||
r = bus_wait_for_jobs(w, arg_quiet, make_extra_args(extra_args));
|
SET_FLAG(flags, BUS_WAIT_JOBS_LOG_ERROR, !arg_quiet);
|
||||||
|
r = bus_wait_for_jobs(w, flags, make_extra_args(extra_args));
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
|
@ -220,7 +220,7 @@ TEST(real_pressure) {
|
|||||||
|
|
||||||
assert_se(sd_bus_message_read(reply, "o", &object) >= 0);
|
assert_se(sd_bus_message_read(reply, "o", &object) >= 0);
|
||||||
|
|
||||||
assert_se(bus_wait_for_jobs_one(w, object, /* quiet= */ false, /* extra_args= */ NULL) >= 0);
|
assert_se(bus_wait_for_jobs_one(w, object, /* flags= */ BUS_WAIT_JOBS_LOG_ERROR, /* extra_args= */ NULL) >= 0);
|
||||||
|
|
||||||
assert_se(sd_event_default(&e) >= 0);
|
assert_se(sd_event_default(&e) >= 0);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user