summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2003-01-08 19:29:00 +0000
committerHavoc Pennington <hp@redhat.com>2003-01-08 19:29:00 +0000
commit509bbe9bded65ddc4039f50ea95a3706ab35ba4f (patch)
tree89de34c4d367b4d20972669784af5b06d0581f76
parent67e33fd84501417c5ba0244e67d91b7a03118bf4 (diff)
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
-rw-r--r--ChangeLog8
-rw-r--r--dbus/dbus-transport-unix.c54
-rw-r--r--dbus/dbus.h1
3 files changed, 51 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 5c16e6d7..6e88efcf 100644
--- 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
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>