diff options
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | dbus/dbus-transport-unix.c | 54 | ||||
-rw-r--r-- | dbus/dbus.h | 1 |
3 files changed, 51 insertions, 12 deletions
@@ -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 diff --git a/dbus/dbus-transport-unix.c b/dbus/dbus-transport-unix.c index ba1528c4..80949b9d 100644 --- a/dbus/dbus-transport-unix.c +++ b/dbus/dbus-transport-unix.c @@ -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); } } diff --git a/dbus/dbus.h b/dbus/dbus.h index fc4f2557..38bfe9f7 100644 --- a/dbus/dbus.h +++ b/dbus/dbus.h @@ -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> |