summaryrefslogtreecommitdiffstats
path: root/dbus
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2003-02-27 05:12:39 +0000
committerHavoc Pennington <hp@redhat.com>2003-02-27 05:12:39 +0000
commitff190005e5e518c1d78fd83b0da3642280ead84c (patch)
tree730cafef9a98ed8e4a964b879ee35e8acbec6018 /dbus
parent13f70ce711630d7f70c0b11fa57639fad95e4afd (diff)
2003-02-27 Havoc Pennington <hp@pobox.com>
* dbus/dbus-connection.c (dbus_connection_send_message_with_reply_and_block): fix doh! doh! doh! bug that resulted in never removing a reply from the queue, no wonder we called get_reply_serial so much ;-) * dbus/dbus-message.c (struct DBusMessage): cache reply serial and client serial instead of demarshaling them every time
Diffstat (limited to 'dbus')
-rw-r--r--dbus/dbus-connection.c2
-rw-r--r--dbus/dbus-message.c29
2 files changed, 25 insertions, 6 deletions
diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c
index 4990cff3..134736d2 100644
--- a/dbus/dbus-connection.c
+++ b/dbus/dbus-connection.c
@@ -1320,7 +1320,7 @@ dbus_connection_send_message_with_reply_and_block (DBusConnection *connectio
if (_dbus_message_get_reply_serial (reply) == client_serial)
{
- _dbus_list_remove (&connection->incoming_messages, link);
+ _dbus_list_remove_link (&connection->incoming_messages, link);
dbus_message_ref (reply);
if (result)
diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c
index 1a112a79..09ebeef8 100644
--- a/dbus/dbus-message.c
+++ b/dbus/dbus-message.c
@@ -91,6 +91,10 @@ struct DBusMessage
HeaderField header_fields[FIELD_LAST]; /**< Track the location
* of each field in "header"
*/
+
+ dbus_int32_t client_serial; /**< Cached client serial value for speed */
+ dbus_int32_t reply_serial; /**< Cached reply serial value for speed */
+
int header_padding; /**< bytes of alignment in header */
DBusString body; /**< Body network data. */
@@ -528,9 +532,10 @@ _dbus_message_set_client_serial (DBusMessage *message,
{
_dbus_assert (!message->locked);
_dbus_assert (_dbus_message_get_client_serial (message) < 0);
-
+
set_int_field (message, FIELD_CLIENT_SERIAL,
client_serial);
+ message->client_serial = client_serial;
}
/**
@@ -547,8 +552,14 @@ _dbus_message_set_reply_serial (DBusMessage *message,
{
_dbus_assert (!message->locked);
- return set_int_field (message, FIELD_REPLY_SERIAL,
- reply_serial);
+ if (set_int_field (message, FIELD_REPLY_SERIAL,
+ reply_serial))
+ {
+ message->reply_serial = reply_serial;
+ return TRUE;
+ }
+ else
+ return FALSE;
}
/**
@@ -566,7 +577,7 @@ _dbus_message_set_reply_serial (DBusMessage *message,
dbus_int32_t
_dbus_message_get_client_serial (DBusMessage *message)
{
- return get_int_field (message, FIELD_CLIENT_SERIAL);
+ return message->client_serial;
}
/**
@@ -579,7 +590,7 @@ _dbus_message_get_client_serial (DBusMessage *message)
dbus_int32_t
_dbus_message_get_reply_serial (DBusMessage *message)
{
- return get_int_field (message, FIELD_REPLY_SERIAL);
+ return message->reply_serial;
}
/**
@@ -728,6 +739,8 @@ dbus_message_new_empty_header (void)
message->refcount = 1;
message->byte_order = DBUS_COMPILER_BYTE_ORDER;
+ message->client_serial = -1;
+ message->reply_serial = -1;
i = 0;
while (i < FIELD_LAST)
@@ -2722,6 +2735,12 @@ _dbus_message_loader_return_buffer (DBusMessageLoader *loader,
_dbus_assert (_dbus_string_get_length (&message->header) == header_len);
_dbus_assert (_dbus_string_get_length (&message->body) == body_len);
+ /* Fill in caches */
+ message->reply_serial = get_int_field (message,
+ FIELD_REPLY_SERIAL);
+ message->client_serial = get_int_field (message,
+ FIELD_CLIENT_SERIAL);
+
_dbus_verbose ("Loaded message %p\n", message);
}
else