2003-01-08 Havoc Pennington <hp@redhat.com>
authorHavoc Pennington <hp@redhat.com>
Wed, 8 Jan 2003 19:29:00 +0000 (19:29 +0000)
committerHavoc Pennington <hp@redhat.com>
Wed, 8 Jan 2003 19:29:00 +0000 (19:29 +0000)
* dbus/dbus-transport-unix.c (unix_do_iteration): add read/write
to the select() as needed for authentication. (should be using
_dbus_poll() not select, but for another day)

* dbus/dbus.h: include dbus/dbus-protocol.h

ChangeLog
dbus/dbus-transport-unix.c
dbus/dbus.h

index 5c16e6d..6e88efc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2003-01-08  Havoc Pennington  <hp@redhat.com>
+
+       * dbus/dbus-transport-unix.c (unix_do_iteration): add read/write 
+       to the select() as needed for authentication. (should be using
+       _dbus_poll() not select, but for another day)
+
+       * dbus/dbus.h: include dbus/dbus-protocol.h
+
 2003-01-08  Anders Carlsson  <andersca@codefactory.se>
 
        * dbus/Makefile.am (dbusinclude_HEADERS): Install
index ba1528c..80949b9 100644 (file)
@@ -838,6 +838,7 @@ unix_messages_pending (DBusTransport *transport,
   check_write_watch (transport);
 }
 
+/* FIXME use _dbus_poll(), not select() */
 static  void
 unix_do_iteration (DBusTransport *transport,
                    unsigned int   flags,
@@ -854,20 +855,49 @@ unix_do_iteration (DBusTransport *transport,
  again:
   
   do_select = FALSE;
-  
+
+  /* the passed in DO_READING/DO_WRITING flags indicate whether to
+   * read/write messages, but regardless of those we may need to block
+   * for reading/writing to do auth.  But if we do reading for auth,
+   * we don't want to read any messages yet if not given DO_READING.
+   */
+
   FD_ZERO (&read_set);
-  if (flags & DBUS_ITERATION_DO_READING)
-    {
-      FD_SET (unix_transport->fd, &read_set);
-      do_select = TRUE;
-    }
-  
   FD_ZERO (&write_set);
-  if (flags & DBUS_ITERATION_DO_WRITING)
+  
+  if (_dbus_transport_get_is_authenticated (transport))
     {
-      FD_SET (unix_transport->fd, &write_set);
-      do_select = TRUE;
+      if (flags & DBUS_ITERATION_DO_READING)
+        {
+          FD_SET (unix_transport->fd, &read_set);
+          do_select = TRUE;
+        }
+      
+      
+      if (flags & DBUS_ITERATION_DO_WRITING)
+        {
+          FD_SET (unix_transport->fd, &write_set);
+          do_select = TRUE;
+        }
     }
+  else
+    {
+      DBusAuthState auth_state;
+      
+      auth_state = _dbus_auth_do_work (transport->auth);
+
+      if (auth_state == DBUS_AUTH_STATE_WAITING_FOR_INPUT)
+        {
+          FD_SET (unix_transport->fd, &read_set);
+          do_select = TRUE;
+        }
+
+      if (auth_state == DBUS_AUTH_STATE_HAVE_BYTES_TO_SEND)
+        {
+          FD_SET (unix_transport->fd, &write_set);
+          do_select = TRUE;
+        }
+    } 
 
   if (do_select)
     {
@@ -915,9 +945,9 @@ unix_do_iteration (DBusTransport *transport,
                              need_read, need_write);
               do_authentication (transport, need_read, need_write);
                                  
-              if (need_read)
+              if (need_read && (flags & DBUS_ITERATION_DO_READING))
                 do_reading (transport);
-              if (need_write)
+              if (need_write && (flags & DBUS_ITERATION_DO_WRITING))
                 do_writing (transport);
             }
         }
index fc4f255..38bfe9f 100644 (file)
@@ -31,6 +31,7 @@
 #include <dbus/dbus-macros.h>
 #include <dbus/dbus-message.h>
 #include <dbus/dbus-message-handler.h>
+#include <dbus/dbus-protocol.h>
 #include <dbus/dbus-server.h>
 #include <dbus/dbus-threads.h>
 #include <dbus/dbus-types.h>