#include "bus-util.h"
#include "cgroup-util.h"
#include "def.h"
+#include "errno-util.h"
#include "fd-util.h"
#include "hexdecoct.h"
#include "hostname-util.h"
#include "macro.h"
+#include "memory-util.h"
#include "missing.h"
#include "parse-util.h"
+#include "path-util.h"
#include "process-util.h"
#include "string-util.h"
#include "strv.h"
-#include "util.h"
#define log_debug_bus_message(m) \
do { \
/* If enabled, synthesizes a local "Connected" signal mirroring the local "Disconnected" signal. This is called
* whenever we fully established a connection, i.e. after the authorization phase, and after receiving the
- * Hello() reply. Or in other words, whenver we enter BUS_RUNNING state.
+ * Hello() reply. Or in other words, whenever we enter BUS_RUNNING state.
*
- * This is useful so that clients can start doing stuff whenver the connection is fully established in a way
+ * This is useful so that clients can start doing stuff whenever the connection is fully established in a way
* that works independently from whether we connected to a full bus or just a direct connection. */
if (!bus->connected_signal)
return r;
bus_message_set_sender_local(bus, m);
+ m->read_counter = ++bus->read_counter;
r = bus_seal_synthetic_message(bus, m);
if (r < 0)
assert_return(ret, -EINVAL);
/* Let's connect to the starter bus if it is set, and
- * otherwise to the bus that is appropropriate for the scope
+ * otherwise to the bus that is appropriate for the scope
* we are running in */
e = secure_getenv("DBUS_STARTER_BUS_TYPE");
b->bus_client = true;
b->is_user = true;
- /* We don't do any per-method access control on the user
- * bus. */
+ /* We don't do any per-method access control on the user bus. */
b->trusted = true;
b->is_local = true;
r = bus_write_message(bus, m, &idx);
if (r < 0) {
- if (IN_SET(r, -ENOTCONN, -ECONNRESET, -EPIPE, -ESHUTDOWN)) {
+ if (ERRNO_IS_DISCONNECT(r)) {
bus_enter_closing(bus);
return -ECONNRESET;
}
r = bus_read_message(bus, false, 0);
if (r < 0) {
- if (IN_SET(r, -ENOTCONN, -ECONNRESET, -EPIPE, -ESHUTDOWN)) {
+ if (ERRNO_IS_DISCONNECT(r)) {
bus_enter_closing(bus);
r = -ECONNRESET;
}
r = dispatch_wqueue(bus);
if (r < 0) {
- if (IN_SET(r, -ENOTCONN, -ECONNRESET, -EPIPE, -ESHUTDOWN)) {
+ if (ERRNO_IS_DISCONNECT(r)) {
bus_enter_closing(bus);
r = -ECONNRESET;
}
if (r < 0)
return r;
+ m->read_counter = ++bus->read_counter;
+
r = bus_seal_synthetic_message(bus, m);
if (r < 0)
return r;
synthetic_reply->realtime = m->realtime;
synthetic_reply->monotonic = m->monotonic;
synthetic_reply->seqnum = m->seqnum;
+ synthetic_reply->read_counter = m->read_counter;
r = bus_seal_synthetic_message(bus, synthetic_reply);
if (r < 0)
if (r < 0)
return r;
+ m->read_counter = ++bus->read_counter;
+
r = bus_seal_synthetic_message(bus, m);
if (r < 0)
return r;
return r;
bus_message_set_sender_local(bus, m);
+ m->read_counter = ++bus->read_counter;
r = bus_seal_synthetic_message(bus, m);
if (r < 0)
assert_not_reached("Unknown state");
}
- if (IN_SET(r, -ENOTCONN, -ECONNRESET, -EPIPE, -ESHUTDOWN)) {
+ if (ERRNO_IS_DISCONNECT(r)) {
bus_enter_closing(bus);
r = 1;
} else if (r < 0)
for (;;) {
r = dispatch_wqueue(bus);
if (r < 0) {
- if (IN_SET(r, -ENOTCONN, -ECONNRESET, -EPIPE, -ESHUTDOWN)) {
+ if (ERRNO_IS_DISCONNECT(r)) {
bus_enter_closing(bus);
return -ECONNRESET;
}
bus->current_slot = match_slot->match_callback.install_slot;
bus->current_handler = add_match_callback;
bus->current_userdata = userdata;
-
- match_slot->match_callback.install_slot = sd_bus_slot_unref(match_slot->match_callback.install_slot);
} else {
if (failed) /* Generic failure handling: destroy the connection */
bus_enter_closing(sd_bus_message_get_bus(m));
r = 1;
}
+ /* We don't need the install method reply slot anymore, let's free it */
+ match_slot->match_callback.install_slot = sd_bus_slot_unref(match_slot->match_callback.install_slot);
+
if (failed && match_slot->floating)
bus_slot_disconnect(match_slot, true);
* then make it floating. */
r = sd_bus_slot_set_floating(s->match_callback.install_slot, true);
} else
- r = bus_add_match_internal(bus, s->match_callback.match_string);
+ r = bus_add_match_internal(bus, s->match_callback.match_string, &s->match_callback.after);
if (r < 0)
goto finish;
if (!e)
return -ENOMEM;
- ret = strjoin(prefix, "/", e);
+ ret = path_join(prefix, e);
if (!ret)
return -ENOMEM;
* For each matched label, the *decoded* label is stored in the
* passed output argument, and the caller is responsible to free
* it. Note that the output arguments are only modified if the
- * actualy path matched the template. Otherwise, they're left
+ * actually path matched the template. Otherwise, they're left
* untouched.
*
* This function returns <0 on error, 0 if the path does not match the