Lines Matching defs:connections
2 /* connection.c Client connections
51 DBusList *completed; /**< List of all completed connections */
53 DBusList *incomplete; /**< List of all not-yet-active connections */
56 DBusHashTable *completed_by_user; /**< Number of completed connections for each UID */
57 DBusTimeout *expire_timeout; /**< Timeout for expiring incomplete connections. */
66 BusConnections *connections;
83 int stamp; /**< connections->stamp last time we were traversed */
90 static void bus_connection_drop_pending_replies (BusConnections *connections,
104 return bus_context_get_loop (d->connections->context);
109 get_connections_for_uid (BusConnections *connections,
117 val = _dbus_hash_table_lookup_ulong (connections->completed_by_user,
126 adjust_connections_for_uid (BusConnections *connections,
132 current_count = get_connections_for_uid (connections, uid);
146 _dbus_hash_table_remove_ulong (connections->completed_by_user, uid);
153 retval = _dbus_hash_table_insert_ulong (connections->completed_by_user,
182 matchmaker = bus_context_get_matchmaker (d->connections->context);
202 while ((transaction = bus_transaction_new (d->connections->context)) == NULL)
257 _dbus_list_remove_link (&d->connections->completed, d->link_in_connection_list);
259 d->connections->n_completed -= 1;
263 if (!adjust_connections_for_uid (d->connections,
270 _dbus_list_remove_link (&d->connections->incomplete, d->link_in_connection_list);
272 d->connections->n_incomplete -= 1;
275 _dbus_assert (d->connections->n_incomplete >= 0);
276 _dbus_assert (d->connections->n_completed >= 0);
279 bus_connection_drop_pending_replies (d->connections, connection);
381 return bus_context_allow_user (d->connections->context, uid);
423 BusConnections *connections;
428 connections = dbus_new0 (BusConnections, 1);
429 if (connections == NULL)
432 connections->completed_by_user = _dbus_hash_table_new (DBUS_HASH_ULONG,
434 if (connections->completed_by_user == NULL)
437 connections->expire_timeout = _dbus_timeout_new (100, /* irrelevant */
439 connections, NULL);
440 if (connections->expire_timeout == NULL)
443 _dbus_timeout_set_enabled (connections->expire_timeout, FALSE);
445 connections->pending_replies = bus_expire_list_new (bus_context_get_loop (context),
448 connections);
449 if (connections->pending_replies == NULL)
453 connections->expire_timeout,
457 connections->refcount = 1;
458 connections->context = context;
460 return connections;
463 bus_expire_list_free (connections->pending_replies);
465 _dbus_timeout_unref (connections->expire_timeout);
467 _dbus_hash_table_unref (connections->completed_by_user);
469 dbus_free (connections);
477 bus_connections_ref (BusConnections *connections)
479 _dbus_assert (connections->refcount > 0);
480 connections->refcount += 1;
482 return connections;
486 bus_connections_unref (BusConnections *connections)
488 _dbus_assert (connections->refcount > 0);
489 connections->refcount -= 1;
490 if (connections->refcount == 0)
493 while (connections->incomplete != NULL)
497 connection = connections->incomplete->data;
505 _dbus_assert (connections->n_incomplete == 0);
507 /* drop all real connections */
508 while (connections->completed != NULL)
512 connection = connections->completed->data;
520 _dbus_assert (connections->n_completed == 0);
522 bus_expire_list_free (connections->pending_replies);
524 _dbus_loop_remove_timeout (bus_context_get_loop (connections->context),
525 connections->expire_timeout,
528 _dbus_timeout_unref (connections->expire_timeout);
530 _dbus_hash_table_unref (connections->completed_by_user);
532 dbus_free (connections);
539 connections,
551 d->connections = connections;
606 bus_context_get_loop (connections->context),
619 if (!_dbus_loop_queue_dispatch (bus_context_get_loop (connections->context), connection))
626 _dbus_list_append_link (&connections->incomplete, d->link_in_connection_list);
627 connections->n_incomplete += 1;
633 * expired connections if possible, and to queue the timeout for our
636 bus_connections_expire_incomplete (connections);
641 if (connections->n_incomplete >
642 bus_context_get_max_incomplete_connections (connections->context))
644 _dbus_verbose ("Number of incomplete connections exceeds max, dropping oldest one\n");
646 _dbus_assert (connections->incomplete != NULL);
650 * connections quickly enough, they can keep anyone else from
654 dbus_connection_close (connections->incomplete->data);
704 bus_connections_expire_incomplete (BusConnections *connections)
710 if (connections->incomplete != NULL)
717 auth_timeout = bus_context_get_auth_timeout (connections->context);
719 link = _dbus_list_get_first_link (&connections->incomplete);
722 DBusList *next = _dbus_list_get_next_link (&connections->incomplete, link);
744 /* We can end the loop, since the connections are in oldest-first order */
756 bus_expire_timeout_set_interval (connections->expire_timeout,
763 BusConnections *connections = data;
768 bus_connections_expire_incomplete (connections);
787 user_database = bus_context_get_user_database (d->connections->context);
855 foreach_active (BusConnections *connections,
861 link = _dbus_list_get_first_link (&connections->completed);
865 DBusList *next = _dbus_list_get_next_link (&connections->completed, link);
877 foreach_inactive (BusConnections *connections,
883 link = _dbus_list_get_first_link (&connections->incomplete);
887 DBusList *next = _dbus_list_get_next_link (&connections->incomplete, link);
900 * #FALSE, stops iterating. Active connections are authenticated
903 * @param connections the connections object
908 bus_connections_foreach_active (BusConnections *connections,
912 foreach_active (connections, function, data);
919 * @param connections the connections object
924 bus_connections_foreach (BusConnections *connections,
928 if (!foreach_active (connections, function, data))
931 foreach_inactive (connections, function, data);
935 bus_connections_get_context (BusConnections *connections)
937 return connections->context;
942 * traversing connections. Note that it assumes we will
948 bus_connections_increment_stamp (BusConnections *connections)
950 connections->stamp += 1;
965 if (d->stamp == d->connections->stamp)
969 d->stamp = d->connections->stamp;
983 return d->connections->context;
995 return d->connections;
1007 return bus_context_get_registry (d->connections->context);
1019 return bus_context_get_activation (d->connections->context);
1031 return bus_context_get_matchmaker (d->connections->context);
1278 d->policy = bus_context_create_client_policy (d->connections->context,
1299 if (!adjust_connections_for_uid (d->connections,
1310 _dbus_list_unlink (&d->connections->incomplete,
1312 d->connections->n_incomplete -= 1;
1313 _dbus_list_append_link (&d->connections->completed,
1315 d->connections->n_completed += 1;
1317 _dbus_assert (d->connections->n_incomplete >= 0);
1318 _dbus_assert (d->connections->n_completed > 0);
1321 bus_connections_expire_incomplete (d->connections);
1344 bus_connections_check_limits (BusConnections *connections,
1356 if (connections->n_completed >=
1357 bus_context_get_max_completed_connections (connections->context))
1360 "The maximum number of active connections has been reached");
1366 if (get_connections_for_uid (connections, uid) >=
1367 bus_context_get_max_connections_per_user (connections->context))
1370 "The maximum number of active connections for UID %lu has been reached",
1392 bus_pending_reply_send_no_reply (BusConnections *connections,
1439 BusConnections *connections = data;
1453 transaction = bus_transaction_new (connections->context);
1457 if (!bus_pending_reply_send_no_reply (connections,
1465 _dbus_list_remove_link (&connections->pending_replies->items,
1474 bus_connection_drop_pending_replies (BusConnections *connections,
1485 link = _dbus_list_get_first_link (&connections->pending_replies->items);
1491 next = _dbus_list_get_next_link (&connections->pending_replies->items,
1505 _dbus_list_remove_link (&connections->pending_replies->items,
1524 bus_expire_timeout_set_interval (connections->pending_replies->timeout,
1536 BusConnections *connections;
1546 if (!_dbus_list_remove (&d->connections->pending_replies->items,
1572 bus_connections_expect_reply (BusConnections *connections,
1594 link = _dbus_list_get_first_link (&connections->pending_replies->items);
1609 link = _dbus_list_get_next_link (&connections->pending_replies->items,
1616 bus_context_get_max_replies_per_connection (connections->context))
1648 if (!_dbus_list_prepend (&connections->pending_replies->items,
1663 _dbus_list_remove (&connections->pending_replies->items, pending);
1670 cprd->connections = connections;
1687 BusConnections *connections;
1697 _dbus_list_prepend_link (&d->connections->pending_replies->items,
1713 _dbus_assert (_dbus_list_find_last (&d->connections->pending_replies->items,
1728 bus_connections_check_reply (BusConnections *connections,
1744 link = _dbus_list_get_first_link (&connections->pending_replies->items);
1757 link = _dbus_list_get_next_link (&connections->pending_replies->items,
1786 cprd->connections = connections;
1788 _dbus_list_unlink (&connections->pending_replies->items,
1791 _dbus_assert (_dbus_list_find_last (&connections->pending_replies->items,
1820 DBusList *connections;
1963 return TRUE; /* silently ignore disconnected connections */
1997 * then we should already be in transaction->connections
2015 if (!_dbus_list_prepend (&transaction->connections, connection))
2061 while ((connection = _dbus_list_pop_first (&transaction->connections)))
2064 _dbus_assert (transaction->connections == NULL);
2115 /* For each connection in transaction->connections
2122 while ((connection = _dbus_list_pop_first (&transaction->connections)))
2125 _dbus_assert (transaction->connections == NULL);
2144 _dbus_list_remove (&to_send->transaction->connections,