X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Flibsystemd-bus%2Fbus-internal.h;h=1726b618418a45f76f6fc976478340e5816bdc6b;hp=6499d6b013a76c5ee0f2b7434a0e8b26c4de298a;hb=40ca29a1370379d43e44c0ed425eecc7218dcbca;hpb=92e189e57297b110a1a12703aa17557e3600cf4f diff --git a/src/libsystemd-bus/bus-internal.h b/src/libsystemd-bus/bus-internal.h index 6499d6b01..1726b6184 100644 --- a/src/libsystemd-bus/bus-internal.h +++ b/src/libsystemd-bus/bus-internal.h @@ -240,14 +240,12 @@ struct sd_bus { uint64_t hello_flags; uint64_t match_cookie; -}; - -static inline void bus_unrefp(sd_bus **b) { - sd_bus_unref(*b); -} -#define _cleanup_bus_unref_ __attribute__((cleanup(bus_unrefp))) -#define _cleanup_bus_error_free_ __attribute__((cleanup(sd_bus_error_free))) + sd_event_source *input_io_event_source; + sd_event_source *output_io_event_source; + sd_event_source *time_event_source; + sd_event *event; +}; #define BUS_DEFAULT_TIMEOUT ((usec_t) (25 * USEC_PER_SEC)) @@ -294,3 +292,9 @@ bool bus_pid_changed(sd_bus *bus); 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)