diff options
author | Havoc Pennington <hp@redhat.com> | 2003-01-19 03:33:35 +0000 |
---|---|---|
committer | Havoc Pennington <hp@redhat.com> | 2003-01-19 03:33:35 +0000 |
commit | 502fbda2201a4e7e50d687f42af29c82e66299bb (patch) | |
tree | 39aef7adb025c95dd016714dffd8577402a4669a /dbus/dbus-connection.c | |
parent | 0363701c341796278041fb9ea7de80eaaf41479a (diff) |
2003-01-18 Havoc Pennington <hp@pobox.com>
* dbus/dbus-transport-unix.c (unix_do_iteration): only do the
reading/writing if read_watch != NULL or write_watch != NULL.
* dbus/dbus-message.c (_dbus_message_loader_return_buffer): fix
the message loader code to actually load message->header and
message->body into the newly-created message.
* dbus/dbus-transport-unix.c (check_write_watch): fix a mem leak
in OOM case
* dbus/dbus-connection.c (dbus_connection_set_max_message_size)
(dbus_connection_get_max_message_size)
(dbus_connection_set_max_live_messages_size)
(dbus_connection_get_max_live_messages_size): implement some
resource limitation functions
* dbus/dbus-resources.c: new file implementing some of the
resource limits stuff
* dbus/dbus-message.c (dbus_message_iter_get_byte_array): add
missing docs, add @todo to handle OOM etc.
* dbus/dbus-marshal.c (_dbus_demarshal_byte_array): add missing
docs
Diffstat (limited to 'dbus/dbus-connection.c')
-rw-r--r-- | dbus/dbus-connection.c | 72 |
1 files changed, 71 insertions, 1 deletions
diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c index 073da8f3..5ffbc57a 100644 --- a/dbus/dbus-connection.c +++ b/dbus/dbus-connection.c @@ -1,7 +1,7 @@ /* -*- mode: C; c-file-style: "gnu" -*- */ /* dbus-connection.c DBusConnection object * - * Copyright (C) 2002 Red Hat Inc. + * Copyright (C) 2002, 2003 Red Hat Inc. * * Licensed under the Academic Free License version 1.2 * @@ -1274,4 +1274,74 @@ _dbus_connection_free_data_slots (DBusConnection *connection) connection->n_slots = 0; } +/** + * Specifies the maximum size message this connection is allowed to + * receive. Larger messages will result in disconnecting the + * connection. + * + * @param connection a #DBusConnection + * @param size maximum message size the connection can receive, in bytes + */ +void +dbus_connection_set_max_message_size (DBusConnection *connection, + long size) +{ + _dbus_transport_set_max_message_size (connection->transport, + size); +} + +/** + * Gets the value set by dbus_connection_set_max_message_size(). + * + * @param connection the connection + * @returns the max size of a single message + */ +long +dbus_connection_get_max_message_size (DBusConnection *connection) +{ + return _dbus_transport_get_max_message_size (connection->transport); +} + +/** + * Sets the maximum total number of bytes that can be used for all messages + * received on this connection. Messages count toward the maximum until + * they are finalized. When the maximum is reached, the connection will + * not read more data until some messages are finalized. + * + * The semantics of the maximum are: if outstanding messages are + * already above the maximum, additional messages will not be read. + * The semantics are not: if the next message would cause us to exceed + * the maximum, we don't read it. The reason is that we don't know the + * size of a message until after we read it. + * + * Thus, the max live messages size can actually be exceeded + * by up to the maximum size of a single message. + * + * Also, if we read say 1024 bytes off the wire in a single read(), + * and that contains a half-dozen small messages, we may exceed the + * size max by that amount. But this should be inconsequential. + * + * @param connection the connection + * @param size the maximum size in bytes of all outstanding messages + */ +void +dbus_connection_set_max_live_messages_size (DBusConnection *connection, + long size) +{ + _dbus_transport_set_max_live_messages_size (connection->transport, + size); +} + +/** + * Gets the value set by dbus_connection_set_max_live_messages_size(). + * + * @param connection the connection + * @returns the max size of all live messages + */ +long +dbus_connection_get_max_live_messages_size (DBusConnection *connection) +{ + return _dbus_transport_get_max_live_messages_size (connection->transport); +} + /** @} */ |