chiark / gitweb /
bus: don't allow recursive invocation of sd_bus_process()
authorLennart Poettering <lennart@poettering.net>
Fri, 5 Apr 2013 01:15:10 +0000 (03:15 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 5 Apr 2013 01:15:10 +0000 (03:15 +0200)
src/libsystemd-bus/bus-internal.h
src/libsystemd-bus/sd-bus.c
src/systemd/sd-bus.h

index feafed0..9cc1c9c 100644 (file)
@@ -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;
index 0964649..8daf922 100644 (file)
@@ -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");
index 122ec95..b89394e 100644 (file)
@@ -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