summaryrefslogtreecommitdiffstats
path: root/dbus/dbus-connection.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2003-01-19 05:14:46 +0000
committerHavoc Pennington <hp@redhat.com>2003-01-19 05:14:46 +0000
commit14cc2707a0318381b5cc68588efc36f61d617b78 (patch)
treeb15d245ad5ff5b650b72ed1aaeda1ed3bcefac30 /dbus/dbus-connection.c
parent502fbda2201a4e7e50d687f42af29c82e66299bb (diff)
2003-01-19 Havoc Pennington <hp@pobox.com>
* dbus/dbus-connection.c (dbus_connection_get_is_authenticated): new function * dbus/dbus-server.c (dbus_server_set_max_connections) (dbus_server_get_max_connections, dbus_server_get_n_connections): keep track of current number of connections, and add API for setting a max (but haven't implemented enforcing the max yet)
Diffstat (limited to 'dbus/dbus-connection.c')
-rw-r--r--dbus/dbus-connection.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c
index 5ffbc57a..4b9d4caa 100644
--- a/dbus/dbus-connection.c
+++ b/dbus/dbus-connection.c
@@ -93,6 +93,8 @@ struct DBusConnection
DBusDataSlot *data_slots; /**< Data slots */
int n_slots; /**< Slots allocated so far. */
+ DBusCounter *connection_counter; /**< Counter that we decrement when finalized */
+
int client_serial; /**< Client serial. Increments each time a message is sent */
unsigned int disconnect_notified : 1; /**< Already called disconnect_function */
};
@@ -390,6 +392,25 @@ _dbus_connection_handler_destroyed (DBusConnection *connection,
}
}
+/**
+ * Adds the counter used to count the number of open connections.
+ * Increments the counter by one, and saves it to be decremented
+ * again when this connection is finalized.
+ *
+ * @param connection a #DBusConnection
+ * @param counter counter that tracks number of connections
+ */
+void
+_dbus_connection_set_connection_counter (DBusConnection *connection,
+ DBusCounter *counter)
+{
+ _dbus_assert (connection->connection_counter == NULL);
+
+ connection->connection_counter = counter;
+ _dbus_counter_ref (connection->connection_counter);
+ _dbus_counter_adjust (connection->connection_counter, 1);
+}
+
/** @} */
/**
@@ -475,6 +496,14 @@ dbus_connection_unref (DBusConnection *connection)
dbus_connection_set_disconnect_function (connection,
NULL, NULL, NULL);
+ if (connection->connection_counter != NULL)
+ {
+ /* subtract ourselves from the counter */
+ _dbus_counter_adjust (connection->connection_counter, - 1);
+ _dbus_counter_unref (connection->connection_counter);
+ connection->connection_counter = NULL;
+ }
+
_dbus_watch_list_free (connection->watches);
connection->watches = NULL;
@@ -553,6 +582,20 @@ dbus_connection_get_is_connected (DBusConnection *connection)
}
/**
+ * Gets whether the connection was authenticated. (Note that
+ * if the connection was authenticated then disconnected,
+ * this function still returns #TRUE)
+ *
+ * @param connection the connection
+ * @returns #TRUE if the connection was ever authenticated
+ */
+dbus_bool_t
+dbus_connection_get_is_authenticated (DBusConnection *connection)
+{
+ return _dbus_transport_get_is_authenticated (connection->transport);
+}
+
+/**
* Adds a message to the outgoing message queue. Does not block to
* write the message to the network; that happens asynchronously. to
* force the message to be written, call dbus_connection_flush().