chiark / gitweb /
bus: properly handle if new objects are installed in the node tree while we are dispa...
[elogind.git] / src / libsystemd-bus / bus-internal.h
index 5795f74693e282536abbf72337ba18ff29cddc73..31e10b2c273e9d59eb4900ed49032a990486eb51 100644 (file)
@@ -289,3 +289,14 @@ int bus_start_running(sd_bus *bus);
 int bus_next_address(sd_bus *bus);
 
 bool bus_pid_changed(sd_bus *bus);
+
+#define OBJECT_PATH_FOREACH_PREFIX(prefix, path)                        \
+        for (char *_slash = ({ strcpy((prefix), (path)); streq((prefix), "/") ? NULL : strrchr((prefix), '/'); }) ; \
+             _slash && !(_slash[(_slash) == (prefix)] = 0);             \
+             _slash = streq((prefix), "/") ? NULL : strrchr((prefix), '/'))
+
+/* If we are invoking callbacks of a bus object, ensure unreffing the
+ * bus from the callback doesn't destroy the object we are working
+ * on */
+#define BUS_DONT_DESTROY(bus) \
+        _cleanup_bus_unref_ sd_bus *_dont_destroy_##bus = sd_bus_ref(bus)