[PATCH xserver 06/20] config: Use NotifyFd for dbus interface

Keith Packard keithp at keithp.com
Wed Nov 11 22:02:06 PST 2015


This uses the NotifyFd interface to monitor the dbus socket rather
than a block/wakeup handler.

Signed-off-by: Keith Packard <keithp at keithp.com>
---
 config/dbus-core.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/config/dbus-core.c b/config/dbus-core.c
index 8351ea4..3c85ad7 100644
--- a/config/dbus-core.c
+++ b/config/dbus-core.c
@@ -48,11 +48,11 @@ static struct dbus_core_info bus_info;
 static CARD32 reconnect_timer(OsTimerPtr timer, CARD32 time, void *arg);
 
 static void
-wakeup_handler(void *data, int num_fds, void *read_mask)
+socket_handler(int fd, int ready, void *data)
 {
     struct dbus_core_info *info = data;
 
-    if (info->connection && num_fds > 0 && FD_ISSET(info->fd, (fd_set *) read_mask)) {
+    if (info->connection) {
         do {
             dbus_connection_read_write_dispatch(info->connection, 0);
         } while (info->connection &&
@@ -62,11 +62,6 @@ wakeup_handler(void *data, int num_fds, void *read_mask)
     }
 }
 
-static void
-block_handler(void *data, struct timeval **tv, void *read_mask)
-{
-}
-
 /**
  * Disconnect (if we haven't already been forcefully disconnected), clean up
  * after ourselves, and call all registered disconnect hooks.
@@ -87,9 +82,8 @@ teardown(void)
     if (bus_info.connection)
         dbus_connection_unref(bus_info.connection);
 
-    RemoveBlockAndWakeupHandlers(block_handler, wakeup_handler, &bus_info);
     if (bus_info.fd != -1)
-        RemoveGeneralSocket(bus_info.fd);
+        RemoveNotifyFd(bus_info.fd);
     bus_info.fd = -1;
     bus_info.connection = NULL;
 
@@ -162,9 +156,7 @@ connect_to_bus(void)
     }
 
     dbus_error_free(&error);
-    AddGeneralSocket(bus_info.fd);
-
-    RegisterBlockAndWakeupHandlers(block_handler, wakeup_handler, &bus_info);
+    SetNotifyFd(bus_info.fd, socket_handler, X_NOTIFY_READ, &bus_info);
 
     for (hook = bus_info.hooks; hook; hook = hook->next) {
         if (hook->connect)
-- 
2.6.1



More information about the xorg-devel mailing list