Commit ebb57e71 authored by Havoc Pennington's avatar Havoc Pennington

2003-03-16 Havoc Pennington <hp@pobox.com>

	* dbus/dbus-string.c (_dbus_string_validate_utf8): oops, unbreak
	this. always run the test suite before commit...

	* bus/*: adapt to DBusConnection API changes

	* glib/dbus-gmain.c: adapt to DBusConnection API changes,
	requires renaming stuff to avoid dbus_connection_dispatch name
	conflict.

	* dbus/dbus-transport.c (_dbus_transport_queue_messages): new
	function

	* dbus/dbus-message.c (_dbus_message_loader_queue_messages):
	separate from _dbus_message_loader_return_buffer()

	* dbus/dbus-connection.c (dbus_connection_get_n_messages): remove
	this, because it's now always broken to use; the number of
	messages in queue vs. the number still buffered by the message
	loader is undefined/meaningless. Should use
	dbus_connection_get_dispatch_state().
	(dbus_connection_dispatch): rename from
	dbus_connection_dispatch_message
parent 021305e5
2003-03-16 Havoc Pennington <hp@pobox.com>
* dbus/dbus-string.c (_dbus_string_validate_utf8): oops, unbreak
this. always run the test suite before commit...
* bus/*: adapt to DBusConnection API changes
* glib/dbus-gmain.c: adapt to DBusConnection API changes,
requires renaming stuff to avoid dbus_connection_dispatch name
conflict.
* dbus/dbus-transport.c (_dbus_transport_queue_messages): new
function
* dbus/dbus-message.c (_dbus_message_loader_queue_messages):
separate from _dbus_message_loader_return_buffer()
* dbus/dbus-connection.c (dbus_connection_get_n_messages): remove
this, because it's now always broken to use; the number of
messages in queue vs. the number still buffered by the message
loader is undefined/meaningless. Should use
dbus_connection_get_dispatch_state().
(dbus_connection_dispatch): rename from
dbus_connection_dispatch_message
2003-03-16 Havoc Pennington <hp@pobox.com>
* dbus/dbus-string.c (_dbus_string_validate_utf8): copy in a real
......
......@@ -141,8 +141,8 @@ connection_watch_callback (DBusWatch *watch,
dbus_connection_handle_watch (connection, watch, condition);
while (dbus_connection_dispatch_message (connection))
;
bus_connection_dispatch_all_messages (connection);
dbus_connection_unref (connection);
}
......@@ -171,8 +171,8 @@ connection_timeout_callback (DBusTimeout *timeout,
dbus_timeout_handle (timeout);
while (dbus_connection_dispatch_message (connection))
;
bus_connection_dispatch_all_messages (connection);
dbus_connection_unref (connection);
}
......
......@@ -514,7 +514,7 @@ kill_client_connection (BusContext *context,
_dbus_assert (bus_test_client_listed (connection));
/* Run disconnect handler in test.c */
if (dbus_connection_dispatch_message (connection))
if (bus_connection_dispatch_one_message (connection))
_dbus_assert_not_reached ("something received on connection being killed other than the disconnect");
_dbus_assert (!dbus_connection_get_is_connected (connection));
......@@ -859,7 +859,7 @@ check_hello_connection (BusContext *context)
dbus_connection_ref (connection);
dbus_connection_disconnect (connection);
/* dispatching disconnect handler will unref once */
if (dbus_connection_dispatch_message (connection))
if (bus_connection_dispatch_one_message (connection))
_dbus_assert_not_reached ("message other than disconnect dispatched after failure to register");
dbus_connection_unref (connection);
_dbus_assert (!bus_test_client_listed (connection));
......@@ -967,19 +967,19 @@ bus_dispatch_test (const DBusString *test_data_dir)
check_hello_connection);
dbus_connection_disconnect (foo);
if (dbus_connection_dispatch_message (foo))
if (bus_connection_dispatch_one_message (foo))
_dbus_assert_not_reached ("extra message in queue");
dbus_connection_unref (foo);
_dbus_assert (!bus_test_client_listed (foo));
dbus_connection_disconnect (bar);
if (dbus_connection_dispatch_message (bar))
if (bus_connection_dispatch_one_message (bar))
_dbus_assert_not_reached ("extra message in queue");
dbus_connection_unref (bar);
_dbus_assert (!bus_test_client_listed (bar));
dbus_connection_disconnect (baz);
if (dbus_connection_dispatch_message (baz))
if (bus_connection_dispatch_one_message (baz))
_dbus_assert_not_reached ("extra message in queue");
dbus_connection_unref (baz);
_dbus_assert (!bus_test_client_listed (baz));
......
......@@ -39,3 +39,20 @@ bus_wait_for_memory (void)
#endif
}
void
bus_connection_dispatch_all_messages (DBusConnection *connection)
{
while (bus_connection_dispatch_one_message (connection))
;
}
dbus_bool_t
bus_connection_dispatch_one_message (DBusConnection *connection)
{
DBusDispatchStatus status;
while ((status = dbus_connection_dispatch (connection)) == DBUS_DISPATCH_NEED_MEMORY)
bus_wait_for_memory ();
return status == DBUS_DISPATCH_DATA_REMAINS;
}
......@@ -25,9 +25,14 @@
#ifndef BUS_UTILS_H
#define BUS_UTILS_H
#include <dbus/dbus.h>
void bus_wait_for_memory (void);
extern const char bus_no_memory_message[];
#define BUS_SET_OOM(error) dbus_set_error ((error), DBUS_ERROR_NO_MEMORY, bus_no_memory_message)
void bus_connection_dispatch_all_messages (DBusConnection *connection);
dbus_bool_t bus_connection_dispatch_one_message (DBusConnection *connection);
#endif /* BUS_ACTIVATION_H */
......@@ -49,7 +49,7 @@
*/
typedef struct
{
char *base_service;
char *base_service; /**< Base service name of this connection */
} BusData;
......@@ -244,7 +244,7 @@ dbus_bus_register (DBusConnection *connection,
* once per connection.
*
* @param connection the connection
* @param the base service name
* @param base_service the base service name
* @returns #FALSE if not enough memory
*/
dbus_bool_t
......
This diff is collapsed.
......@@ -56,6 +56,13 @@ typedef enum
* can be present in current state). */
} DBusWatchFlags;
typedef enum
{
DBUS_DISPATCH_DATA_REMAINS, /**< There is more data to potentially convert to messages. */
DBUS_DISPATCH_COMPLETE, /**< All currently available data has been processed. */
DBUS_DISPATCH_NEED_MEMORY /**< More memory is needed to continue. */
} DBusDispatchStatus;
typedef dbus_bool_t (* DBusAddWatchFunction) (DBusWatch *watch,
void *data);
typedef void (* DBusWatchToggledFunction) (DBusWatch *watch,
......@@ -70,58 +77,52 @@ typedef void (* DBusTimeoutToggledFunction) (DBusTimeout *timeout,
typedef void (* DBusRemoveTimeoutFunction) (DBusTimeout *timeout,
void *data);
DBusConnection* dbus_connection_open (const char *address,
DBusResultCode *result);
void dbus_connection_ref (DBusConnection *connection);
void dbus_connection_unref (DBusConnection *connection);
void dbus_connection_disconnect (DBusConnection *connection);
dbus_bool_t dbus_connection_get_is_connected (DBusConnection *connection);
dbus_bool_t dbus_connection_get_is_authenticated (DBusConnection *connection);
void dbus_connection_flush (DBusConnection *connection);
int dbus_connection_get_n_messages (DBusConnection *connection);
DBusMessage* dbus_connection_borrow_message (DBusConnection *connection);
void dbus_connection_return_message (DBusConnection *connection,
DBusMessage *message);
void dbus_connection_steal_borrowed_message (DBusConnection *connection,
DBusMessage *message);
DBusMessage* dbus_connection_pop_message (DBusConnection *connection);
dbus_bool_t dbus_connection_dispatch_message (DBusConnection *connection);
dbus_bool_t dbus_connection_send (DBusConnection *connection,
DBusMessage *message,
dbus_int32_t *client_serial);
dbus_bool_t dbus_connection_send_with_reply (DBusConnection *connection,
DBusMessage *message,
DBusMessageHandler *reply_handler,
int timeout_milliseconds);
DBusMessage *dbus_connection_send_with_reply_and_block (DBusConnection *connection,
DBusMessage *message,
int timeout_milliseconds,
DBusError *error);
dbus_bool_t dbus_connection_set_watch_functions (DBusConnection *connection,
DBusAddWatchFunction add_function,
DBusRemoveWatchFunction remove_function,
DBusWatchToggledFunction toggled_function,
void *data,
DBusFreeFunction free_data_function);
dbus_bool_t dbus_connection_set_timeout_functions (DBusConnection *connection,
DBusAddTimeoutFunction add_function,
DBusRemoveTimeoutFunction remove_function,
DBusTimeoutToggledFunction toggled_function,
void *data,
DBusFreeFunction free_data_function);
void dbus_connection_set_wakeup_main_function (DBusConnection *connection,
DBusWakeupMainFunction wakeup_main_function,
void *data,
DBusFreeFunction free_data_function);
void dbus_connection_handle_watch (DBusConnection *connection,
DBusWatch *watch,
unsigned int condition);
DBusConnection* dbus_connection_open (const char *address,
DBusResultCode *result);
void dbus_connection_ref (DBusConnection *connection);
void dbus_connection_unref (DBusConnection *connection);
void dbus_connection_disconnect (DBusConnection *connection);
dbus_bool_t dbus_connection_get_is_connected (DBusConnection *connection);
dbus_bool_t dbus_connection_get_is_authenticated (DBusConnection *connection);
void dbus_connection_flush (DBusConnection *connection);
DBusMessage* dbus_connection_borrow_message (DBusConnection *connection);
void dbus_connection_return_message (DBusConnection *connection,
DBusMessage *message);
void dbus_connection_steal_borrowed_message (DBusConnection *connection,
DBusMessage *message);
DBusMessage* dbus_connection_pop_message (DBusConnection *connection);
DBusDispatchStatus dbus_connection_get_dispatch_status (DBusConnection *connection);
DBusDispatchStatus dbus_connection_dispatch (DBusConnection *connection);
dbus_bool_t dbus_connection_send (DBusConnection *connection,
DBusMessage *message,
dbus_int32_t *client_serial);
dbus_bool_t dbus_connection_send_with_reply (DBusConnection *connection,
DBusMessage *message,
DBusMessageHandler *reply_handler,
int timeout_milliseconds);
DBusMessage * dbus_connection_send_with_reply_and_block (DBusConnection *connection,
DBusMessage *message,
int timeout_milliseconds,
DBusError *error);
dbus_bool_t dbus_connection_set_watch_functions (DBusConnection *connection,
DBusAddWatchFunction add_function,
DBusRemoveWatchFunction remove_function,
DBusWatchToggledFunction toggled_function,
void *data,
DBusFreeFunction free_data_function);
dbus_bool_t dbus_connection_set_timeout_functions (DBusConnection *connection,
DBusAddTimeoutFunction add_function,
DBusRemoveTimeoutFunction remove_function,
DBusTimeoutToggledFunction toggled_function,
void *data,
DBusFreeFunction free_data_function);
void dbus_connection_set_wakeup_main_function (DBusConnection *connection,
DBusWakeupMainFunction wakeup_main_function,
void *data,
DBusFreeFunction free_data_function);
void dbus_connection_handle_watch (DBusConnection *connection,
DBusWatch *watch,
unsigned int condition);
int dbus_watch_get_fd (DBusWatch *watch);
......
......@@ -156,7 +156,9 @@ _dbus_set_fail_alloc_counter (int until_next_fail)
fail_alloc_counter = until_next_fail;
#if 0
_dbus_verbose ("Set fail alloc counter = %d\n", fail_alloc_counter);
#endif
}
/**
......
......@@ -100,7 +100,7 @@ struct DBusMemPool
DBusFreedElement *free_elements; /**< a free list of elements to recycle */
DBusMemBlock *blocks; /**< blocks of memory from malloc() */
int allocated_elements; /* Count of outstanding allocated elements */
int allocated_elements; /**< Count of outstanding allocated elements */
};
/** @} */
......
......@@ -137,7 +137,7 @@ _dbus_message_handler_handle_message (DBusMessageHandler *handler,
dbus_mutex_unlock (message_handler_lock);
/* This function doesn't ref handler/connection/message
* since that's done in dbus_connection_dispatch_message().
* since that's done in dbus_connection_dispatch().
*/
if (function != NULL)
return (* function) (handler, connection, message, user_data);
......
......@@ -51,7 +51,8 @@ void _dbus_message_loader_get_buffer (DBusMessageLoader
void _dbus_message_loader_return_buffer (DBusMessageLoader *loader,
DBusString *buffer,
int bytes_read);
dbus_bool_t _dbus_message_loader_queue_messages (DBusMessageLoader *loader);
DBusMessage* _dbus_message_loader_peek_message (DBusMessageLoader *loader);
DBusMessage* _dbus_message_loader_pop_message (DBusMessageLoader *loader);
DBusList* _dbus_message_loader_pop_message_link (DBusMessageLoader *loader);
......
......@@ -2676,12 +2676,6 @@ decode_header_data (const DBusString *data,
* in. This function must always be called, even if no bytes were
* successfully read.
*
* @todo if we run out of memory in here, we offer no way for calling
* code to handle it, i.e. they can't re-run the message parsing
* attempt. Perhaps much of this code could be moved to pop_message()?
* But then that may need to distinguish NULL return for no messages
* from NULL return for errors.
*
* @param loader the loader.
* @param buffer the buffer.
* @param bytes_read number of bytes that were read into the buffer.
......@@ -2695,9 +2689,19 @@ _dbus_message_loader_return_buffer (DBusMessageLoader *loader,
_dbus_assert (buffer == &loader->data);
loader->buffer_outstanding = FALSE;
}
/**
* Converts buffered data into messages.
*
* @param loader the loader.
* @returns #TRUE if we had enough memory to finish.
*/
dbus_bool_t
_dbus_message_loader_queue_messages (DBusMessageLoader *loader)
{
if (loader->corrupted)
return;
return TRUE;
while (_dbus_string_get_length (&loader->data) >= 16)
{
......@@ -2715,7 +2719,7 @@ _dbus_message_loader_return_buffer (DBusMessageLoader *loader,
_dbus_verbose ("Message has protocol version %d ours is %d\n",
(int) header_data[2], DBUS_MAJOR_PROTOCOL_VERSION);
loader->corrupted = TRUE;
return;
return TRUE;
}
byte_order = header_data[0];
......@@ -2726,7 +2730,7 @@ _dbus_message_loader_return_buffer (DBusMessageLoader *loader,
_dbus_verbose ("Message with bad byte order '%c' received\n",
byte_order);
loader->corrupted = TRUE;
return;
return TRUE;
}
header_len_unsigned = _dbus_unpack_uint32 (byte_order, header_data + 4);
......@@ -2737,7 +2741,7 @@ _dbus_message_loader_return_buffer (DBusMessageLoader *loader,
_dbus_verbose ("Message had broken too-small header length %u\n",
header_len_unsigned);
loader->corrupted = TRUE;
return;
return TRUE;
}
if (header_len_unsigned > (unsigned) MAX_SANE_MESSAGE_SIZE ||
......@@ -2747,7 +2751,7 @@ _dbus_message_loader_return_buffer (DBusMessageLoader *loader,
header_len_unsigned,
body_len_unsigned);
loader->corrupted = TRUE;
return;
return TRUE;
}
/* Now that we know the values are in signed range, get
......@@ -2762,7 +2766,7 @@ _dbus_message_loader_return_buffer (DBusMessageLoader *loader,
_dbus_verbose ("header length %d is not aligned to 8 bytes\n",
header_len);
loader->corrupted = TRUE;
return;
return TRUE;
}
if (header_len + body_len > loader->max_message_size)
......@@ -2770,7 +2774,7 @@ _dbus_message_loader_return_buffer (DBusMessageLoader *loader,
_dbus_verbose ("Message claimed length header = %d body = %d exceeds max message length %d\n",
header_len, body_len, loader->max_message_size);
loader->corrupted = TRUE;
return;
return TRUE;
}
if (_dbus_string_get_length (&loader->data) >= (header_len + body_len))
......@@ -2787,7 +2791,7 @@ _dbus_message_loader_return_buffer (DBusMessageLoader *loader,
{
_dbus_verbose ("Header was invalid\n");
loader->corrupted = TRUE;
return;
return TRUE;
}
next_arg = header_len;
......@@ -2801,7 +2805,7 @@ _dbus_message_loader_return_buffer (DBusMessageLoader *loader,
&next_arg))
{
loader->corrupted = TRUE;
return;
return TRUE;
}
_dbus_assert (next_arg > prev);
......@@ -2813,12 +2817,12 @@ _dbus_message_loader_return_buffer (DBusMessageLoader *loader,
next_arg, header_len, body_len,
header_len + body_len);
loader->corrupted = TRUE;
return;
return TRUE;
}
message = dbus_message_new_empty_header ();
if (message == NULL)
break; /* ugh, postpone this I guess. */
return FALSE;
message->byte_order = byte_order;
message->header_padding = header_padding;
......@@ -2834,7 +2838,7 @@ _dbus_message_loader_return_buffer (DBusMessageLoader *loader,
if (!_dbus_list_append (&loader->messages, message))
{
dbus_message_unref (message);
break;
return FALSE;
}
_dbus_assert (_dbus_string_get_length (&message->header) == 0);
......@@ -2847,7 +2851,7 @@ _dbus_message_loader_return_buffer (DBusMessageLoader *loader,
{
_dbus_list_remove_last (&loader->messages, message);
dbus_message_unref (message);
break;
return FALSE;
}
if (!_dbus_string_move_len (&loader->data, 0, body_len, &message->body, 0))
......@@ -2861,7 +2865,7 @@ _dbus_message_loader_return_buffer (DBusMessageLoader *loader,
_dbus_list_remove_last (&loader->messages, message);
dbus_message_unref (message);
break;
return FALSE;
}
_dbus_assert (_dbus_string_get_length (&message->header) == header_len);
......@@ -2876,14 +2880,32 @@ _dbus_message_loader_return_buffer (DBusMessageLoader *loader,
_dbus_verbose ("Loaded message %p\n", message);
}
else
break;
return TRUE;
}
return TRUE;
}
/**
* Peeks at first loaded message, returns #NULL if no messages have
* been queued.
*
* @param loader the loader.
* @returns the next message, or #NULL if none.
*/
DBusMessage*
_dbus_message_loader_peek_message (DBusMessageLoader *loader)
{
if (loader->messages)
return loader->messages->data;
else
return NULL;
}
/**
* Pops a loaded message (passing ownership of the message
* to the caller). Returns #NULL if no messages have been
* loaded.
* queued.
*
* @param loader the loader.
* @returns the next message, or #NULL if none.
......@@ -3153,6 +3175,9 @@ check_have_valid_message (DBusMessageLoader *loader)
message = NULL;
retval = FALSE;
if (!_dbus_message_loader_queue_messages (loader))
_dbus_assert_not_reached ("no memory to queue messages");
if (_dbus_message_loader_get_is_corrupted (loader))
{
......@@ -3195,6 +3220,9 @@ check_invalid_message (DBusMessageLoader *loader)
dbus_bool_t retval;
retval = FALSE;
if (!_dbus_message_loader_queue_messages (loader))
_dbus_assert_not_reached ("no memory to queue messages");
if (!_dbus_message_loader_get_is_corrupted (loader))
{
......@@ -3216,6 +3244,9 @@ check_incomplete_message (DBusMessageLoader *loader)
message = NULL;
retval = FALSE;
if (!_dbus_message_loader_queue_messages (loader))
_dbus_assert_not_reached ("no memory to queue messages");
if (_dbus_message_loader_get_is_corrupted (loader))
{
......@@ -3242,6 +3273,9 @@ static dbus_bool_t
check_loader_results (DBusMessageLoader *loader,
DBusMessageValidity validity)
{
if (!_dbus_message_loader_queue_messages (loader))
_dbus_assert_not_reached ("no memory to queue messages");
switch (validity)
{
case _DBUS_MESSAGE_VALID:
......@@ -3735,6 +3769,9 @@ _dbus_message_test (const char *test_data_dir)
dbus_message_unref (message);
/* Now pop back the message */
if (!_dbus_message_loader_queue_messages (loader))
_dbus_assert_not_reached ("no memory to queue messages");
if (_dbus_message_loader_get_is_corrupted (loader))
_dbus_assert_not_reached ("message loader corrupted");
......
......@@ -151,7 +151,7 @@ _dbus_server_remove_watch (DBusServer *server,
* function on a watch that was not previously added.
*
* @param server the server.
* @param timeout the timeout to toggle.
* @param watch the watch to toggle.
* @param enabled whether to enable or disable
*/
void
......
......@@ -2395,6 +2395,7 @@ _dbus_string_validate_utf8 (const DBusString *str,
int len)
{
const unsigned char *p;
const unsigned char *end;
DBUS_CONST_STRING_PREAMBLE (str);
_dbus_assert (start >= 0);
_dbus_assert (start <= real->len);
......@@ -2403,9 +2404,10 @@ _dbus_string_validate_utf8 (const DBusString *str,
if (len > real->len - start)
return FALSE;
p = real->str;
p = real->str + start;
end = p + len;
while (p - real->str < len && *p)
while (p < end)
{
int i, mask = 0, char_len;
dbus_unichar_t result;
......@@ -2416,20 +2418,20 @@ _dbus_string_validate_utf8 (const DBusString *str,
if (char_len == -1)
break;
/* check that the expected number of bytes exists in real->str */
if ((len - (p - real->str)) < char_len)
/* check that the expected number of bytes exists in the remaining length */
if ((end - p) < char_len)
break;
UTF8_GET (result, p, i, mask, char_len);
if (UTF8_LENGTH (result) != char_len) /* Check for overlong UTF-8 */
break;
break;
if (result == (dbus_unichar_t)-1)
break;
if (!UNICODE_VALID (result))
break;
break;
p += char_len;
}
......@@ -2437,7 +2439,7 @@ _dbus_string_validate_utf8 (const DBusString *str,
/* See that we covered the entire length if a length was
* passed in
*/
if (p != (real->str + len))
if (p != end)
return FALSE;
else
return TRUE;
......
......@@ -178,37 +178,6 @@ do_io_error (DBusTransport *transport)
_dbus_transport_unref (transport);
}
static void
queue_messages (DBusTransport *transport)
{
DBusList *link;
/* Queue any messages */
while ((link = _dbus_message_loader_pop_message_link (transport->loader)))
{
DBusMessage *message;
message = link->data;
_dbus_verbose ("queueing received message %p\n", message);
_dbus_message_add_size_counter (message, transport->live_messages_size);
/* pass ownership of link and message ref to connection */
_dbus_connection_queue_received_message_link (transport->connection,
link);
}
if (_dbus_message_loader_get_is_corrupted (transport->loader))
{
_dbus_verbose ("Corrupted message stream, disconnecting\n");
do_io_error (transport);
}
/* check read watch in case we've now exceeded max outstanding messages */
check_read_watch (transport);
}
/* return value is whether we successfully read any new data. */
static dbus_bool_t
read_data_into_auth (DBusTransport *transport)
......@@ -398,8 +367,6 @@ recover_unused_bytes (DBusTransport *transport)
orig_len);
}
queue_messages (transport);
return;
nomem:
......@@ -777,7 +744,8 @@ do_reading (DBusTransport *transport)
total += bytes_read;
queue_messages (transport);
if (_dbus_transport_queue_messages (transport) == DBUS_DISPATCH_NEED_MEMORY)
goto out;
/* Try reading more data until we get EAGAIN and return, or
* exceed max bytes per iteration. If in blocking mode of
......
......@@ -506,6 +506,70 @@ _dbus_transport_do_iteration (DBusTransport *transport,
_dbus_transport_unref (transport);
}
/**
* Reports our current dispatch status (whether there's buffered
* data to be queued as messages, or not, or we need memory).
*
* @param transport the transport
* @returns current status
*/
DBusDispatchStatus
_dbus_transport_get_dispatch_status (DBusTransport *transport)
{
if (_dbus_counter_get_value (transport->live_messages_size) >= transport->max_live_messages_size)
return DBUS_DISPATCH_COMPLETE; /* complete for now */
if (!_dbus_message_loader_queue_messages (transport->loader))
return DBUS_DISPATCH_NEED_MEMORY;
if (_dbus_message_loader_peek_message (transport->loader) != NULL)
return DBUS_DISPATCH_DATA_REMAINS;
else
return DBUS_DISPATCH_COMPLETE;
}
/**
* Processes data we've read while handling a watch, potentially
* converting some of it to messages and queueing those messages on
* the connection.
*
* @param transport the transport
* @returns #TRUE if we had enough memory to queue all messages
*/
dbus_bool_t
_dbus_transport_queue_messages (DBusTransport *transport)
{
DBusDispatchStatus status;
/* Queue any messages */
while ((status = _dbus_transport_get_dispatch_status (transport)) == DBUS_DISPATCH_DATA_REMAINS)
{
DBusMessage *message;
DBusList *link;
link = _dbus_message_loader_pop_message_link (transport->loader);
_dbus_assert (link != NULL);
message = link->data;
_dbus_verbose ("queueing received message %p\n", message);
_dbus_message_add_size_counter (message, transport->live_messages_size);
/* pass ownership of link and message ref to connection */
_dbus_connection_queue_received_message_link (transport->connection,
link);
}
if (_dbus_message_loader_get_is_corrupted (transport->loader))
{
_dbus_verbose ("Corrupted message stream, disconnecting\n");
_dbus_transport_disconnect (transport);
}
return status != DBUS_DISPATCH_NEED_MEMORY;
}
/**
* See dbus_connection_set_max_message_size().
*
......
......@@ -30,29 +30,31 @@ DBUS_BEGIN_DECLS;
typedef struct DBusTransport DBusTransport;
DBusTransport* _dbus_transport_open (const char *address,
DBusResultCode *result);
void _dbus_transport_ref (DBusTransport *transport);
void _dbus_transport_unref (DBusTransport *transport);
void _dbus_transport_disconnect (DBusTransport *transport);
dbus_bool_t _dbus_transport_get_is_connected (DBusTransport *transport);
dbus_bool_t _dbus_transport_get_is_authenticated (DBusTransport *transport);
void _dbus_transport_handle_watch (DBusTransport *transport,
DBusWatch *watch,
unsigned int condition);
dbus_bool_t _dbus_transport_set_connection (DBusTransport *transport,
DBusConnection *connection);
void _dbus_transport_messages_pending (DBusTransport *transport,
int queue_length);
void _dbus_transport_do_iteration (DBusTransport *transport,
unsigned int flags,
int timeout_milliseconds);
void _dbus_transport_set_max_message_size (DBusTransport *transport,