-
- /* Try reading more data until we get EAGAIN and return, or
- * exceed max bytes per iteration. If in blocking mode of
- * course we'll block instead of returning.
- */
- goto again;
- }
-
- out:
- if (oom)
- return FALSE;
- else
- return TRUE;
-}
-
-static dbus_bool_t
-unix_handle_watch (DBusTransport *transport,
- DBusWatch *watch,
- unsigned int flags)
-{
- DBusTransportUnix *unix_transport = (DBusTransportUnix*) transport;
-
- _dbus_assert (watch == unix_transport->read_watch ||
- watch == unix_transport->write_watch);
-
- if (flags & (DBUS_WATCH_HANGUP | DBUS_WATCH_ERROR))
- {
- _dbus_transport_disconnect (transport);
- return TRUE;
- }
-
- if (watch == unix_transport->read_watch &&
- (flags & DBUS_WATCH_READABLE))
- {
-#if 0
- _dbus_verbose ("handling read watch\n");
-#endif
- if (!do_authentication (transport, TRUE, FALSE))
- return FALSE;
-
- if (!do_reading (transport))
- return FALSE;
- }
- else if (watch == unix_transport->write_watch &&
- (flags & DBUS_WATCH_WRITABLE))
- {
-#if 0
- _dbus_verbose ("handling write watch\n");
-#endif
- if (!do_authentication (transport, FALSE, TRUE))
- return FALSE;
-
- if (!do_writing (transport))
- return FALSE;
- }
-
- return TRUE;
-}
-
-static void
-unix_disconnect (DBusTransport *transport)
-{
- DBusTransportUnix *unix_transport = (DBusTransportUnix*) transport;
-
- free_watches (transport);
-
- _dbus_close (unix_transport->fd, NULL);
- unix_transport->fd = -1;
-}
-
-static dbus_bool_t
-unix_connection_set (DBusTransport *transport)
-{
- DBusTransportUnix *unix_transport = (DBusTransportUnix*) transport;
-
- if (!_dbus_connection_add_watch (transport->connection,
- unix_transport->write_watch))
- return FALSE;
-
- if (!_dbus_connection_add_watch (transport->connection,
- unix_transport->read_watch))
- {
- _dbus_connection_remove_watch (transport->connection,
- unix_transport->write_watch);
- return FALSE;
- }
-
- check_read_watch (transport);
- check_write_watch (transport);
-
- return TRUE;
-}
-
-static void
-unix_messages_pending (DBusTransport *transport,
- int messages_pending)
-{
- check_write_watch (transport);
-}