diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-10-14 19:53:56 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-10-14 19:53:56 +0200 |
commit | 8ce2afd6347dcf01e33fe1ff257e2b0fffa8edfe (patch) | |
tree | f90e1b693239377c283be59ead467993887c5ec2 /src/libsystemd-bus/bus-internal.h | |
parent | d68888227d2e1093f8e18753ba2e10a1cab7c6ad (diff) |
bus: make sure that we always keep a ref to the bus when we dispatch callbacks
Otherwise the callback might unref the bus we are processing and destroy
the object while we are processing it.
Diffstat (limited to 'src/libsystemd-bus/bus-internal.h')
-rw-r--r-- | src/libsystemd-bus/bus-internal.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/libsystemd-bus/bus-internal.h b/src/libsystemd-bus/bus-internal.h index 6499d6b013..31e10b2c27 100644 --- a/src/libsystemd-bus/bus-internal.h +++ b/src/libsystemd-bus/bus-internal.h @@ -294,3 +294,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) |