diff options
author | Felipe Sateler <fsateler@debian.org> | 2019-02-20 21:24:33 -0300 |
---|---|---|
committer | Felipe Sateler <fsateler@debian.org> | 2019-02-20 21:24:33 -0300 |
commit | 7c20daf69c4411979b7f8902f3601d1cdc56cc07 (patch) | |
tree | d59b9989ce55ed23693e80974d94c856f1c2c8b1 /src/libsystemd/sd-bus | |
parent | 6e866b331d7cd4a5e0759dd160dea6edabd3678e (diff) | |
download | systemd-8334ea1698549f336631f37714499a91b140a271.tar.gz |
New upstream version 241upstream/241
Diffstat (limited to 'src/libsystemd/sd-bus')
-rw-r--r-- | src/libsystemd/sd-bus/bus-dump.h | 4 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/bus-match.c | 4 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/bus-objects.c | 12 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/bus-protocol.h | 12 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/bus-socket.c | 11 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/sd-bus.c | 13 |
6 files changed, 33 insertions, 23 deletions
diff --git a/src/libsystemd/sd-bus/bus-dump.h b/src/libsystemd/sd-bus/bus-dump.h index 373a86dd4f..a1b67c6b14 100644 --- a/src/libsystemd/sd-bus/bus-dump.h +++ b/src/libsystemd/sd-bus/bus-dump.h @@ -7,8 +7,8 @@ #include "sd-bus.h" enum { - BUS_MESSAGE_DUMP_WITH_HEADER = 1, - BUS_MESSAGE_DUMP_SUBTREE_ONLY = 2, + BUS_MESSAGE_DUMP_WITH_HEADER = 1 << 0, + BUS_MESSAGE_DUMP_SUBTREE_ONLY = 1 << 1, }; int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags); diff --git a/src/libsystemd/sd-bus/bus-match.c b/src/libsystemd/sd-bus/bus-match.c index ad135406f6..9642de10c3 100644 --- a/src/libsystemd/sd-bus/bus-match.c +++ b/src/libsystemd/sd-bus/bus-match.c @@ -49,11 +49,11 @@ * ` BUS_MATCH_LEAF: E */ -static inline bool BUS_MATCH_IS_COMPARE(enum bus_match_node_type t) { +static bool BUS_MATCH_IS_COMPARE(enum bus_match_node_type t) { return t >= BUS_MATCH_SENDER && t <= BUS_MATCH_ARG_HAS_LAST; } -static inline bool BUS_MATCH_CAN_HASH(enum bus_match_node_type t) { +static bool BUS_MATCH_CAN_HASH(enum bus_match_node_type t) { return (t >= BUS_MATCH_MESSAGE_TYPE && t <= BUS_MATCH_PATH) || (t >= BUS_MATCH_ARG && t <= BUS_MATCH_ARG_LAST) || (t >= BUS_MATCH_ARG_HAS && t <= BUS_MATCH_ARG_HAS_LAST); diff --git a/src/libsystemd/sd-bus/bus-objects.c b/src/libsystemd/sd-bus/bus-objects.c index d0538104ae..58329f3fe7 100644 --- a/src/libsystemd/sd-bus/bus-objects.c +++ b/src/libsystemd/sd-bus/bus-objects.c @@ -1149,7 +1149,7 @@ static int object_manager_serialize_path_and_fallbacks( return 0; /* Second, add fallback vtables registered for any of the prefixes */ - prefix = alloca(strlen(path) + 1); + prefix = newa(char, strlen(path) + 1); OBJECT_PATH_FOREACH_PREFIX(prefix, path) { r = object_manager_serialize_path(bus, reply, prefix, path, true, error); if (r < 0) @@ -1500,7 +1500,7 @@ static int bus_find_parent_object_manager(sd_bus *bus, struct node **out, const if (!n) { char *prefix; - prefix = alloca(strlen(path) + 1); + prefix = newa(char, strlen(path) + 1); OBJECT_PATH_FOREACH_PREFIX(prefix, path) { n = hashmap_get(bus->nodes, prefix); if (n) @@ -2114,7 +2114,7 @@ _public_ int sd_bus_emit_properties_changed_strv( if (bus->nodes_modified) continue; - prefix = alloca(strlen(path) + 1); + prefix = newa(char, strlen(path) + 1); OBJECT_PATH_FOREACH_PREFIX(prefix, path) { r = emit_properties_changed_on_interface(bus, prefix, path, interface, true, &found_interface, names); if (r != 0) @@ -2291,7 +2291,7 @@ static int object_added_append_all(sd_bus *bus, sd_bus_message *m, const char *p if (bus->nodes_modified) return 0; - prefix = alloca(strlen(path) + 1); + prefix = newa(char, strlen(path) + 1); OBJECT_PATH_FOREACH_PREFIX(prefix, path) { r = object_added_append_all_prefix(bus, m, s, prefix, path, true); if (r < 0) @@ -2462,7 +2462,7 @@ static int object_removed_append_all(sd_bus *bus, sd_bus_message *m, const char if (bus->nodes_modified) return 0; - prefix = alloca(strlen(path) + 1); + prefix = newa(char, strlen(path) + 1); OBJECT_PATH_FOREACH_PREFIX(prefix, path) { r = object_removed_append_all_prefix(bus, m, s, prefix, path, true); if (r < 0) @@ -2626,7 +2626,7 @@ static int interfaces_added_append_one( if (bus->nodes_modified) return 0; - prefix = alloca(strlen(path) + 1); + prefix = newa(char, strlen(path) + 1); OBJECT_PATH_FOREACH_PREFIX(prefix, path) { r = interfaces_added_append_one_prefix(bus, m, prefix, path, interface, true); if (r != 0) diff --git a/src/libsystemd/sd-bus/bus-protocol.h b/src/libsystemd/sd-bus/bus-protocol.h index a5f4724aa9..d01fd8e6a3 100644 --- a/src/libsystemd/sd-bus/bus-protocol.h +++ b/src/libsystemd/sd-bus/bus-protocol.h @@ -54,9 +54,9 @@ enum { /* Flags */ enum { - BUS_MESSAGE_NO_REPLY_EXPECTED = 1, - BUS_MESSAGE_NO_AUTO_START = 2, - BUS_MESSAGE_ALLOW_INTERACTIVE_AUTHORIZATION = 4, + BUS_MESSAGE_NO_REPLY_EXPECTED = 1 << 0, + BUS_MESSAGE_NO_AUTO_START = 1 << 1, + BUS_MESSAGE_ALLOW_INTERACTIVE_AUTHORIZATION = 1 << 2, }; /* Header fields */ @@ -78,9 +78,9 @@ enum { /* RequestName parameters */ enum { - BUS_NAME_ALLOW_REPLACEMENT = 1, - BUS_NAME_REPLACE_EXISTING = 2, - BUS_NAME_DO_NOT_QUEUE = 4 + BUS_NAME_ALLOW_REPLACEMENT = 1 << 0, + BUS_NAME_REPLACE_EXISTING = 1 << 1, + BUS_NAME_DO_NOT_QUEUE = 1 << 2, }; /* RequestName returns */ diff --git a/src/libsystemd/sd-bus/bus-socket.c b/src/libsystemd/sd-bus/bus-socket.c index ed185131b8..441b4a816f 100644 --- a/src/libsystemd/sd-bus/bus-socket.c +++ b/src/libsystemd/sd-bus/bus-socket.c @@ -981,7 +981,7 @@ int bus_socket_write_message(sd_bus *bus, sd_bus_message *m, size_t *idx) { return r; n = m->n_iovec * sizeof(struct iovec); - iov = alloca(n); + iov = newa(struct iovec, n); memcpy_safe(iov, m->iovec, n); j = 0; @@ -1072,7 +1072,7 @@ static int bus_socket_read_message_need(sd_bus *bus, size_t *need) { } static int bus_socket_make_message(sd_bus *bus, size_t size) { - sd_bus_message *t; + sd_bus_message *t = NULL; void *b; int r; @@ -1097,7 +1097,9 @@ static int bus_socket_make_message(sd_bus *bus, size_t size) { bus->fds, bus->n_fds, NULL, &t); - if (r < 0) { + if (r == -EBADMSG) + log_debug_errno(r, "Received invalid message from connection %s, dropping.", strna(bus->description)); + else if (r < 0) { free(b); return r; } @@ -1108,7 +1110,8 @@ static int bus_socket_make_message(sd_bus *bus, size_t size) { bus->fds = NULL; bus->n_fds = 0; - bus->rqueue[bus->rqueue_size++] = t; + if (t) + bus->rqueue[bus->rqueue_size++] = t; return 1; } diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c index 3b00bc8157..1ff858f32d 100644 --- a/src/libsystemd/sd-bus/sd-bus.c +++ b/src/libsystemd/sd-bus/sd-bus.c @@ -1556,17 +1556,24 @@ _public_ void sd_bus_close(sd_bus *bus) { bus_close_inotify_fd(bus); } +_public_ sd_bus *sd_bus_close_unref(sd_bus *bus) { + if (!bus) + return NULL; + + sd_bus_close(bus); + + return sd_bus_unref(bus); +} + _public_ sd_bus* sd_bus_flush_close_unref(sd_bus *bus) { if (!bus) return NULL; /* Have to do this before flush() to prevent hang */ bus_kill_exec(bus); - sd_bus_flush(bus); - sd_bus_close(bus); - return sd_bus_unref(bus); + return sd_bus_close_unref(bus); } void bus_enter_closing(sd_bus *bus) { |