/* connection.c Client connections
*
* Copyright (C) 2003 Red Hat, Inc.
+ * Copyright (C) 2013 Samsung Electronics
*
* Licensed under the Academic Free License version 2.1
*
BusConnectionData *d;
BusService *service;
BusMatchmaker *matchmaker;
+#ifdef ENABLE_KDBUS_TRANSPORT
+ dbus_bool_t is_phantom = FALSE;
+#endif
d = BUS_CONNECTION_DATA (connection);
_dbus_assert (d != NULL);
_dbus_verbose ("%s disconnected, dropping all service ownership and releasing\n",
d->name ? d->name : "(inactive)");
+#ifdef ENABLE_KDBUS_TRANSPORT
+ if(bus_context_is_kdbus(d->connections->context) && (strcmp(bus_connection_get_name(connection), ":1.1")))
+ is_phantom = TRUE;
+#endif
+
/* Delete our match rules */
if (d->n_match_rules > 0)
{
dbus_connection_set_data (connection,
connection_data_slot,
NULL, NULL);
-
- dbus_connection_unref (connection);
+
+#ifdef ENABLE_KDBUS_TRANSPORT
+ if(is_phantom)
+ dbus_connection_unref_phantom(connection);
+ else
+#endif
+ dbus_connection_unref (connection);
}
static dbus_bool_t
_dbus_loop_remove_watch (connection_get_loop (connection), watch);
}
+static void
+toggle_connection_watch (DBusWatch *watch,
+ void *data)
+{
+ DBusConnection *connection = data;
+
+ _dbus_loop_toggle_watch (connection_get_loop (connection), watch);
+}
+
static dbus_bool_t
add_connection_timeout (DBusTimeout *timeout,
void *data)
d->connections = connections;
d->connection = connection;
- _dbus_get_current_time (&d->connection_tv_sec,
- &d->connection_tv_usec);
+ _dbus_get_monotonic_time (&d->connection_tv_sec,
+ &d->connection_tv_usec);
_dbus_assert (connection_data_slot >= 0);
if (!dbus_connection_set_watch_functions (connection,
add_connection_watch,
remove_connection_watch,
- NULL,
+ toggle_connection_watch,
connection,
NULL))
goto out;
DBusList *link;
int auth_timeout;
- _dbus_get_current_time (&tv_sec, &tv_usec);
+ _dbus_get_monotonic_time (&tv_sec, &tv_usec);
auth_timeout = bus_context_get_auth_timeout (connections->context);
link = _dbus_list_get_first_link (&connections->incomplete);
foreach_inactive (connections, function, data);
}
+#ifdef ENABLE_KDBUS_TRANSPORT
+DBusConnection*
+bus_connections_find_conn_by_name(BusConnections *connections, const char* name)
+{
+ DBusList *link;
+
+ link = _dbus_list_get_first_link (&connections->completed);
+ while (link != NULL)
+ {
+ DBusConnection *connection = link->data;
+ DBusList *next = _dbus_list_get_next_link (&connections->completed, link);
+
+ if (!strcmp(bus_connection_get_name(connection), name))
+ return connection;
+
+ link = next;
+ }
+
+ return NULL;
+}
+#endif
+
BusContext*
bus_connections_get_context (BusConnections *connections)
{
return d->n_services_owned;
}
+#ifdef ENABLE_KDBUS_TRANSPORT
+DBusList**
+bus_connection_get_services_owned (DBusConnection *connection)
+{
+ BusConnectionData *d;
+ d = BUS_CONNECTION_DATA (connection);
+ _dbus_assert (d != NULL);
+
+ return &d->services_owned;
+}
+#endif
+
dbus_bool_t
bus_connection_complete (DBusConnection *connection,
const DBusString *name,
cprd->pending = pending;
cprd->connections = connections;
- _dbus_get_current_time (&pending->expire_item.added_tv_sec,
- &pending->expire_item.added_tv_usec);
+ _dbus_get_monotonic_time (&pending->expire_item.added_tv_sec,
+ &pending->expire_item.added_tv_usec);
_dbus_verbose ("Added pending reply %p, replier %p receiver %p serial %u\n",
pending,
if (!dbus_message_set_sender (message, DBUS_SERVICE_DBUS))
return FALSE;
- if (bus_connection_is_active (connection))
+#ifdef ENABLE_KDBUS_TRANSPORT
+ if(!bus_context_is_kdbus(bus_transaction_get_context (transaction))) /* we can't set destination on the basis of connection when on kdbus*/
+#endif
+ if (bus_connection_is_active (connection))
{
if (!dbus_message_set_destination (message,
bus_connection_get_name (connection)))