-
- bytes_read = _dbus_read_socket (socket_transport->fd,
- buffer, socket_transport->max_bytes_read_per_iteration);
-
+
+#ifdef HAVE_UNIX_FD_PASSING
+ if (DBUS_TRANSPORT_CAN_SEND_UNIX_FD(transport))
+ {
+ int *fds, n_fds;
+
+ if (!_dbus_message_loader_get_unix_fds(transport->loader, &fds, &n_fds))
+ {
+ _dbus_verbose ("Out of memory reading file descriptors\n");
+ _dbus_message_loader_return_buffer (transport->loader, buffer, 0);
+ oom = TRUE;
+ goto out;
+ }
+
+ bytes_read = _dbus_read_socket_with_unix_fds(socket_transport->fd,
+ buffer,
+ socket_transport->max_bytes_read_per_iteration,
+ fds, &n_fds);
+
+ if (bytes_read >= 0 && n_fds > 0)
+ _dbus_verbose("Read %i unix fds\n", n_fds);
+
+ _dbus_message_loader_return_unix_fds(transport->loader, fds, bytes_read < 0 ? 0 : n_fds);
+ }
+ else
+#endif
+ {
+ bytes_read = _dbus_read_socket (socket_transport->fd,
+ buffer, socket_transport->max_bytes_read_per_iteration);
+ }
+