return 0;
}
-_public_ int sd_bus_set_exec(sd_bus *bus, const char *path, char *const argv[]) {
+_public_ int sd_bus_set_exec(sd_bus *bus, const char *path, char *const *argv) {
_cleanup_strv_free_ char **a = NULL;
int r;
int bus_start_running(sd_bus *bus) {
struct reply_callback *c;
- Iterator i;
usec_t n;
int r;
* adding a fixed value to all entries should not alter the internal order. */
n = now(CLOCK_MONOTONIC);
- ORDERED_HASHMAP_FOREACH(c, bus->reply_callbacks, i) {
+ ORDERED_HASHMAP_FOREACH(c, bus->reply_callbacks) {
if (c->timeout_usec == 0)
continue;
int bus_set_address_system(sd_bus *b) {
const char *e;
+ int r;
+
assert(b);
e = secure_getenv("DBUS_SYSTEM_BUS_ADDRESS");
- return sd_bus_set_address(b, e ?: DEFAULT_SYSTEM_BUS_ADDRESS);
+
+ r = sd_bus_set_address(b, e ?: DEFAULT_SYSTEM_BUS_ADDRESS);
+ if (r >= 0)
+ b->is_system = true;
+ return r;
}
_public_ int sd_bus_open_system_with_description(sd_bus **ret, const char *description) {
return r;
b->bus_client = true;
- b->is_system = true;
/* Let's do per-method access control on the system bus. We
* need the caller's UID and capability set for that. */
int bus_set_address_user(sd_bus *b) {
const char *a;
_cleanup_free_ char *_a = NULL;
+ int r;
assert(b);
a = _a;
}
- return sd_bus_set_address(b, a);
+ r = sd_bus_set_address(b, a);
+ if (r >= 0)
+ b->is_user = true;
+ return r;
}
_public_ int sd_bus_open_user_with_description(sd_bus **ret, const char *description) {
return r;
b->bus_client = true;
- b->is_user = true;
/* We don't do any per-method access control on the user bus. */
b->trusted = true;
return ret;
}
-static int bus_read_message(sd_bus *bus, bool hint_priority, int64_t priority) {
+static int bus_read_message(sd_bus *bus) {
assert(bus);
return bus_socket_read_message(bus);
bus->rqueue_size--;
}
-static int dispatch_rqueue(sd_bus *bus, bool hint_priority, int64_t priority, sd_bus_message **m) {
+static int dispatch_rqueue(sd_bus *bus, sd_bus_message **m) {
int r, ret = 0;
assert(bus);
assert(m);
assert(IN_SET(bus->state, BUS_RUNNING, BUS_HELLO));
- /* Note that the priority logic is only available on kdbus,
- * where the rqueue is unused. We check the rqueue here
- * anyway, because it's simple... */
-
for (;;) {
if (bus->rqueue_size > 0) {
/* Dispatch a queued message */
}
/* Try to read a new message */
- r = bus_read_message(bus, hint_priority, priority);
+ r = bus_read_message(bus);
if (r < 0)
return r;
if (r == 0) {
i++;
}
- r = bus_read_message(bus, false, 0);
+ r = bus_read_message(bus);
if (r < 0) {
if (ERRNO_IS_DISCONNECT(r)) {
bus_enter_closing(bus);
return 1;
}
-static int process_running(sd_bus *bus, bool hint_priority, int64_t priority, sd_bus_message **ret) {
+static int process_running(sd_bus *bus, sd_bus_message **ret) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
int r;
if (r != 0)
goto null_message;
- r = dispatch_rqueue(bus, hint_priority, priority, &m);
+ r = dispatch_rqueue(bus, &m);
if (r < 0)
return r;
if (!m)
return r;
}
-static int bus_process_internal(sd_bus *bus, bool hint_priority, int64_t priority, sd_bus_message **ret) {
+static int bus_process_internal(sd_bus *bus, sd_bus_message **ret) {
int r;
/* Returns 0 when we didn't do anything. This should cause the
case BUS_RUNNING:
case BUS_HELLO:
- r = process_running(bus, hint_priority, priority, ret);
+ r = process_running(bus, ret);
if (r >= 0)
return r;
}
_public_ int sd_bus_process(sd_bus *bus, sd_bus_message **ret) {
- return bus_process_internal(bus, false, 0, ret);
+ return bus_process_internal(bus, ret);
}
_public_ int sd_bus_process_priority(sd_bus *bus, int64_t priority, sd_bus_message **ret) {
- return bus_process_internal(bus, true, priority, ret);
+ return bus_process_internal(bus, ret);
}
static int bus_poll(sd_bus *bus, bool need_more, uint64_t timeout_usec) {
r = ppoll(p, n, m == USEC_INFINITY ? NULL : timespec_store(&ts, m), NULL);
if (r < 0)
return -errno;
+ if (r == 0)
+ return 0;
- return r > 0 ? 1 : 0;
+ if (p[0].revents & POLLNVAL)
+ return -EBADF;
+ if (n >= 2 && (p[1].revents & POLLNVAL))
+ return -EBADF;
+
+ return 1;
}
_public_ int sd_bus_wait(sd_bus *bus, uint64_t timeout_usec) {