mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-18 22:58:54 +02:00
GDBus: Only rewrite serial number if g_dbus_message_get_serial() returns 0
While this a dangerous thing to allow (collissions, reply_serial not matching up etc.), the added flexibility makes this a good trade-off - for example, with this feature, it's now a lot easier to build message routers. Signed-off-by: David Zeuthen <davidz@redhat.com>
This commit is contained in:
@@ -1026,7 +1026,11 @@ g_dbus_connection_send_message_unlocked (GDBusConnection *connection,
|
|||||||
if (blob == NULL)
|
if (blob == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
serial_to_use = ++connection->priv->last_serial; /* TODO: handle overflow */
|
serial_to_use = g_dbus_message_get_serial (message);
|
||||||
|
if (serial_to_use == 0)
|
||||||
|
{
|
||||||
|
serial_to_use = ++connection->priv->last_serial; /* TODO: handle overflow */
|
||||||
|
}
|
||||||
|
|
||||||
switch (blob[0])
|
switch (blob[0])
|
||||||
{
|
{
|
||||||
@@ -1079,8 +1083,11 @@ g_dbus_connection_send_message_unlocked (GDBusConnection *connection,
|
|||||||
*
|
*
|
||||||
* Asynchronously sends @message to the peer represented by @connection.
|
* Asynchronously sends @message to the peer represented by @connection.
|
||||||
*
|
*
|
||||||
* If @out_serial is not %NULL, then the serial number assigned to
|
* If g_dbus_message_get_serial() returns non-zero for @message, then
|
||||||
* @message by @connection will be written to this location prior to
|
* that value is used for the message serial number. Otherwise a
|
||||||
|
* serial number will be assigned by @connection and set on @message
|
||||||
|
* via g_dbus_message_set_serial(). If @out_serial is not %NULL, then
|
||||||
|
* the serial number used will be written to this location prior to
|
||||||
* submitting the message to the underlying transport.
|
* submitting the message to the underlying transport.
|
||||||
*
|
*
|
||||||
* If @connection is closed then the operation will fail with
|
* If @connection is closed then the operation will fail with
|
||||||
@@ -1392,8 +1399,11 @@ g_dbus_connection_send_message_with_reply_unlocked (GDBusConnection *connect
|
|||||||
*
|
*
|
||||||
* Asynchronously sends @message to the peer represented by @connection.
|
* Asynchronously sends @message to the peer represented by @connection.
|
||||||
*
|
*
|
||||||
* If @out_serial is not %NULL, then the serial number assigned to
|
* If g_dbus_message_get_serial() returns non-zero for @message, then
|
||||||
* @message by @connection will be written to this location prior to
|
* that value is used for the message serial number. Otherwise a
|
||||||
|
* serial number will be assigned by @connection and set on @message
|
||||||
|
* via g_dbus_message_set_serial(). If @out_serial is not %NULL, then
|
||||||
|
* the serial number used will be written to this location prior to
|
||||||
* submitting the message to the underlying transport.
|
* submitting the message to the underlying transport.
|
||||||
*
|
*
|
||||||
* If @connection is closed then the operation will fail with
|
* If @connection is closed then the operation will fail with
|
||||||
@@ -1525,8 +1535,11 @@ send_message_with_reply_sync_cb (GDBusConnection *connection,
|
|||||||
* timeout is reached. See g_dbus_connection_send_message_with_reply()
|
* timeout is reached. See g_dbus_connection_send_message_with_reply()
|
||||||
* for the asynchronous version of this method.
|
* for the asynchronous version of this method.
|
||||||
*
|
*
|
||||||
* If @out_serial is not %NULL, then the serial number assigned to
|
* If g_dbus_message_get_serial() returns non-zero for @message, then
|
||||||
* @message by @connection will be written to this location prior to
|
* that value is used for the message serial number. Otherwise a
|
||||||
|
* serial number will be assigned by @connection and set on @message
|
||||||
|
* via g_dbus_message_set_serial(). If @out_serial is not %NULL, then
|
||||||
|
* the serial number used will be written to this location prior to
|
||||||
* submitting the message to the underlying transport.
|
* submitting the message to the underlying transport.
|
||||||
*
|
*
|
||||||
* If @connection is closed then the operation will fail with
|
* If @connection is closed then the operation will fail with
|
||||||
|
@@ -618,12 +618,14 @@ test_connection_filter (void)
|
|||||||
while (data.num_handled == 0)
|
while (data.num_handled == 0)
|
||||||
g_thread_yield ();
|
g_thread_yield ();
|
||||||
|
|
||||||
|
g_dbus_message_set_serial (m, 0);
|
||||||
g_dbus_connection_send_message (c, m, &data.serial, &error);
|
g_dbus_connection_send_message (c, m, &data.serial, &error);
|
||||||
g_assert_no_error (error);
|
g_assert_no_error (error);
|
||||||
|
|
||||||
while (data.num_handled == 1)
|
while (data.num_handled == 1)
|
||||||
g_thread_yield ();
|
g_thread_yield ();
|
||||||
|
|
||||||
|
g_dbus_message_set_serial (m, 0);
|
||||||
r = g_dbus_connection_send_message_with_reply_sync (c,
|
r = g_dbus_connection_send_message_with_reply_sync (c,
|
||||||
m,
|
m,
|
||||||
-1,
|
-1,
|
||||||
@@ -637,6 +639,7 @@ test_connection_filter (void)
|
|||||||
|
|
||||||
g_dbus_connection_remove_filter (c, filter_id);
|
g_dbus_connection_remove_filter (c, filter_id);
|
||||||
|
|
||||||
|
g_dbus_message_set_serial (m, 0);
|
||||||
r = g_dbus_connection_send_message_with_reply_sync (c,
|
r = g_dbus_connection_send_message_with_reply_sync (c,
|
||||||
m,
|
m,
|
||||||
-1,
|
-1,
|
||||||
|
Reference in New Issue
Block a user