diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-04-05 03:15:10 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-04-05 03:15:10 +0200 |
commit | 6807947e56d7d1b40ec4e984a5f631fb6d5a6834 (patch) | |
tree | 158b40fa0a3fca53be27cc275910bc9730a037f7 | |
parent | 4b9c52209b197a6ccf4b027a9a71c63390b33ba5 (diff) |
bus: don't allow recursive invocation of sd_bus_process()
-rw-r--r-- | src/libsystemd-bus/bus-internal.h | 1 | ||||
-rw-r--r-- | src/libsystemd-bus/sd-bus.c | 10 | ||||
-rw-r--r-- | src/systemd/sd-bus.h | 1 |
3 files changed, 10 insertions, 2 deletions
diff --git a/src/libsystemd-bus/bus-internal.h b/src/libsystemd-bus/bus-internal.h index feafed0876..9cc1c9c899 100644 --- a/src/libsystemd-bus/bus-internal.h +++ b/src/libsystemd-bus/bus-internal.h @@ -85,6 +85,7 @@ struct sd_bus { bool anonymous_auth:1; bool prefer_readv:1; bool prefer_writev:1; + bool processing:1; void *rbuffer; size_t rbuffer_size; diff --git a/src/libsystemd-bus/sd-bus.c b/src/libsystemd-bus/sd-bus.c index 0964649e39..8daf922ded 100644 --- a/src/libsystemd-bus/sd-bus.c +++ b/src/libsystemd-bus/sd-bus.c @@ -1845,6 +1845,10 @@ int sd_bus_process(sd_bus *bus, sd_bus_message **ret) { if (bus->input_fd < 0) return -ENOTCONN; + /* We don't allow recursively invoking sd_bus_process(). */ + if (bus->processing) + return -EBUSY; + switch (bus->state) { case BUS_UNSET: @@ -1870,7 +1874,11 @@ int sd_bus_process(sd_bus *bus, sd_bus_message **ret) { case BUS_RUNNING: case BUS_HELLO: - return process_running(bus, ret); + bus->processing = true; + r = process_running(bus, ret); + bus->processing = false; + + return r; } assert_not_reached("Unknown state"); diff --git a/src/systemd/sd-bus.h b/src/systemd/sd-bus.h index 122ec954ca..b89394e974 100644 --- a/src/systemd/sd-bus.h +++ b/src/systemd/sd-bus.h @@ -34,7 +34,6 @@ extern "C" { /* TODO: * - allow registration/removl of callbacks from within callbacks - * - don't allow recursive processing * * - add page donation logic * - api for appending/reading fixed arrays |