+dbus_bool_t
+_dbus_connection_putback_message (DBusConnection *connection,
+ DBusMessage *after_message,
+ DBusMessage *message,
+ DBusError *error)
+{
+ DBusDispatchStatus status;
+ DBusList *message_link = _dbus_list_alloc_link (message);
+ DBusList *after_link;
+ if (message_link == NULL)
+ {
+ _DBUS_SET_OOM (error);
+ return FALSE;
+ }
+ dbus_message_ref (message);
+
+ CONNECTION_LOCK (connection);
+ _dbus_connection_acquire_dispatch (connection);
+ HAVE_LOCK_CHECK (connection);
+
+ after_link = _dbus_list_find_first(&connection->incoming_messages, after_message);
+ _dbus_list_insert_after_link (&connection->incoming_messages, after_link, message_link);
+ connection->n_incoming += 1;
+
+ _dbus_verbose ("Message %p (%s %s %s '%s') put back into queue %p, %d incoming\n",
+ message_link->data,
+ dbus_message_type_to_string (dbus_message_get_type (message_link->data)),
+ dbus_message_get_interface (message_link->data) ?
+ dbus_message_get_interface (message_link->data) :
+ "no interface",
+ dbus_message_get_member (message_link->data) ?
+ dbus_message_get_member (message_link->data) :
+ "no member",
+ dbus_message_get_signature (message_link->data),
+ connection, connection->n_incoming);
+
+ _dbus_message_trace_ref (message_link->data, -1, -1,
+ "_dbus_connection_putback_message");
+
+ _dbus_connection_release_dispatch (connection);
+
+ status = _dbus_connection_get_dispatch_status_unlocked (connection);
+ _dbus_connection_update_dispatch_status_and_unlock (connection, status);
+
+ return TRUE;
+}
+
+dbus_bool_t
+_dbus_connection_remove_message (DBusConnection *connection,
+ DBusMessage *message)
+{
+ DBusDispatchStatus status;
+ dbus_bool_t removed;
+
+ CONNECTION_LOCK (connection);
+ _dbus_connection_acquire_dispatch (connection);
+ HAVE_LOCK_CHECK (connection);
+
+ removed = _dbus_list_remove(&connection->incoming_messages, message);
+
+ if (removed)
+ {
+ connection->n_incoming -= 1;
+ dbus_message_unref(message);
+ _dbus_verbose ("Message %p removed from incoming queue\n", message);
+ }
+ else
+ _dbus_verbose ("Message %p not found in the incoming queue\n", message);
+
+ _dbus_connection_release_dispatch (connection);
+
+ status = _dbus_connection_get_dispatch_status_unlocked (connection);
+ _dbus_connection_update_dispatch_status_and_unlock (connection, status);
+ return removed;
+}
+