summaryrefslogtreecommitdiffstats
path: root/bus
diff options
context:
space:
mode:
Diffstat (limited to 'bus')
-rw-r--r--bus/connection.c8
-rw-r--r--bus/dispatch.c10
-rw-r--r--bus/utils.c17
-rw-r--r--bus/utils.h5
4 files changed, 31 insertions, 9 deletions
diff --git a/bus/connection.c b/bus/connection.c
index 3308df0f..2169d8ab 100644
--- a/bus/connection.c
+++ b/bus/connection.c
@@ -141,8 +141,8 @@ connection_watch_callback (DBusWatch *watch,
dbus_connection_handle_watch (connection, watch, condition);
- while (dbus_connection_dispatch_message (connection))
- ;
+ bus_connection_dispatch_all_messages (connection);
+
dbus_connection_unref (connection);
}
@@ -171,8 +171,8 @@ connection_timeout_callback (DBusTimeout *timeout,
dbus_timeout_handle (timeout);
- while (dbus_connection_dispatch_message (connection))
- ;
+ bus_connection_dispatch_all_messages (connection);
+
dbus_connection_unref (connection);
}
diff --git a/bus/dispatch.c b/bus/dispatch.c
index 0fe4be19..3c96d704 100644
--- a/bus/dispatch.c
+++ b/bus/dispatch.c
@@ -514,7 +514,7 @@ kill_client_connection (BusContext *context,
_dbus_assert (bus_test_client_listed (connection));
/* Run disconnect handler in test.c */
- if (dbus_connection_dispatch_message (connection))
+ if (bus_connection_dispatch_one_message (connection))
_dbus_assert_not_reached ("something received on connection being killed other than the disconnect");
_dbus_assert (!dbus_connection_get_is_connected (connection));
@@ -859,7 +859,7 @@ check_hello_connection (BusContext *context)
dbus_connection_ref (connection);
dbus_connection_disconnect (connection);
/* dispatching disconnect handler will unref once */
- if (dbus_connection_dispatch_message (connection))
+ if (bus_connection_dispatch_one_message (connection))
_dbus_assert_not_reached ("message other than disconnect dispatched after failure to register");
dbus_connection_unref (connection);
_dbus_assert (!bus_test_client_listed (connection));
@@ -967,19 +967,19 @@ bus_dispatch_test (const DBusString *test_data_dir)
check_hello_connection);
dbus_connection_disconnect (foo);
- if (dbus_connection_dispatch_message (foo))
+ if (bus_connection_dispatch_one_message (foo))
_dbus_assert_not_reached ("extra message in queue");
dbus_connection_unref (foo);
_dbus_assert (!bus_test_client_listed (foo));
dbus_connection_disconnect (bar);
- if (dbus_connection_dispatch_message (bar))
+ if (bus_connection_dispatch_one_message (bar))
_dbus_assert_not_reached ("extra message in queue");
dbus_connection_unref (bar);
_dbus_assert (!bus_test_client_listed (bar));
dbus_connection_disconnect (baz);
- if (dbus_connection_dispatch_message (baz))
+ if (bus_connection_dispatch_one_message (baz))
_dbus_assert_not_reached ("extra message in queue");
dbus_connection_unref (baz);
_dbus_assert (!bus_test_client_listed (baz));
diff --git a/bus/utils.c b/bus/utils.c
index fadfc140..8a68d8a4 100644
--- a/bus/utils.c
+++ b/bus/utils.c
@@ -39,3 +39,20 @@ bus_wait_for_memory (void)
#endif
}
+void
+bus_connection_dispatch_all_messages (DBusConnection *connection)
+{
+ while (bus_connection_dispatch_one_message (connection))
+ ;
+}
+
+dbus_bool_t
+bus_connection_dispatch_one_message (DBusConnection *connection)
+{
+ DBusDispatchStatus status;
+
+ while ((status = dbus_connection_dispatch (connection)) == DBUS_DISPATCH_NEED_MEMORY)
+ bus_wait_for_memory ();
+
+ return status == DBUS_DISPATCH_DATA_REMAINS;
+}
diff --git a/bus/utils.h b/bus/utils.h
index 41eb5557..968ece37 100644
--- a/bus/utils.h
+++ b/bus/utils.h
@@ -25,9 +25,14 @@
#ifndef BUS_UTILS_H
#define BUS_UTILS_H
+#include <dbus/dbus.h>
+
void bus_wait_for_memory (void);
extern const char bus_no_memory_message[];
#define BUS_SET_OOM(error) dbus_set_error ((error), DBUS_ERROR_NO_MEMORY, bus_no_memory_message)
+void bus_connection_dispatch_all_messages (DBusConnection *connection);
+dbus_bool_t bus_connection_dispatch_one_message (DBusConnection *connection);
+
#endif /* BUS_ACTIVATION_H */