* [PATCH] dbus: Don't send replies to messages with no reply flag
2016-04-18 14:31 [PATCH 1/2] dbus: Add private _dbus_message_new_error Andrew Zaborowski
@ 2016-04-18 14:31 ` Andrew Zaborowski
0 siblings, 0 replies; 3+ messages in thread
From: Andrew Zaborowski @ 2016-04-18 14:31 UTC (permalink / raw)
To: ell
[-- Attachment #1: Type: text/plain, Size: 2313 bytes --]
Kdbus doesn't store the cookies for messages that have the no reply flag
and throws error when a reply is sent with reply_cookie that it doesn't
know. It's not fatal, but we also save some cycles by not sending the
message.
We mark those replies with reply_serial == 0, rather than setting a
"discard" flag on the message, because the method call's serial is
effectively an invalid reply_serial value.
---
ell/dbus-message.c | 10 +++++++---
ell/dbus.c | 10 ++++++++++
2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/ell/dbus-message.c b/ell/dbus-message.c
index aecf398..9286f0e 100644
--- a/ell/dbus-message.c
+++ b/ell/dbus-message.c
@@ -319,7 +319,8 @@ LIB_EXPORT struct l_dbus_message *l_dbus_message_new_method_return(
DBUS_MESSAGE_FLAG_NO_REPLY_EXPECTED,
hdr->version);
- message->reply_serial = _dbus_message_get_serial(method_call);
+ if (!l_dbus_message_get_no_reply(method_call))
+ message->reply_serial = _dbus_message_get_serial(method_call);
sender = l_dbus_message_get_sender(method_call);
if (sender)
@@ -368,11 +369,14 @@ LIB_EXPORT struct l_dbus_message *l_dbus_message_new_error_valist(
{
char str[1024];
struct dbus_header *hdr = method_call->header;
+ uint32_t reply_serial = 0;
vsnprintf(str, sizeof(str), format, args);
- return _dbus_message_new_error(hdr->version,
- _dbus_message_get_serial(method_call),
+ if (!l_dbus_message_get_no_reply(method_call))
+ reply_serial = _dbus_message_get_serial(method_call);
+
+ return _dbus_message_new_error(hdr->version, reply_serial,
l_dbus_message_get_sender(method_call),
name, str);
}
diff --git a/ell/dbus.c b/ell/dbus.c
index 9bb47ae..84b3fa1 100644
--- a/ell/dbus.c
+++ b/ell/dbus.c
@@ -325,6 +325,16 @@ static uint32_t send_message(struct l_dbus *dbus, bool priority,
void *user_data, l_dbus_destroy_func_t destroy)
{
struct message_callback *callback;
+ enum dbus_message_type type;
+
+ type = _dbus_message_get_type(message);
+
+ if ((type == DBUS_MESSAGE_TYPE_METHOD_RETURN ||
+ type == DBUS_MESSAGE_TYPE_ERROR) &&
+ _dbus_message_get_reply_serial(message) == 0) {
+ l_dbus_message_unref(message);
+ return 0;
+ }
callback = l_new(struct message_callback, 1);
--
2.5.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH] dbus: Don't send replies to messages with no reply flag
@ 2016-11-09 10:22 Andrew Zaborowski
2016-11-09 20:16 ` Denis Kenzior
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Zaborowski @ 2016-11-09 10:22 UTC (permalink / raw)
To: ell
[-- Attachment #1: Type: text/plain, Size: 2332 bytes --]
Kdbus doesn't store the cookies for messages that have the no reply flag
and throws error when a reply is sent with reply_cookie that it doesn't
know. It's not fatal, but we save some cycles by not sending the message
with both dbus versions.
We mark those replies with reply_serial == 0, rather than setting a
"discard" flag on the message, because the method call's serial is
effectively an invalid reply_serial value.
---
ell/dbus-message.c | 10 +++++++---
ell/dbus.c | 10 ++++++++++
2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/ell/dbus-message.c b/ell/dbus-message.c
index 072a902..3b44fb8 100644
--- a/ell/dbus-message.c
+++ b/ell/dbus-message.c
@@ -326,7 +326,8 @@ LIB_EXPORT struct l_dbus_message *l_dbus_message_new_method_return(
DBUS_MESSAGE_FLAG_NO_REPLY_EXPECTED,
hdr->version);
- message->reply_serial = _dbus_message_get_serial(method_call);
+ if (!l_dbus_message_get_no_reply(method_call))
+ message->reply_serial = _dbus_message_get_serial(method_call);
sender = l_dbus_message_get_sender(method_call);
if (sender)
@@ -369,11 +370,14 @@ LIB_EXPORT struct l_dbus_message *l_dbus_message_new_error_valist(
{
char str[1024];
struct dbus_header *hdr = method_call->header;
+ uint32_t reply_serial = 0;
vsnprintf(str, sizeof(str), format, args);
- return _dbus_message_new_error(hdr->version,
- _dbus_message_get_serial(method_call),
+ if (!l_dbus_message_get_no_reply(method_call))
+ reply_serial = _dbus_message_get_serial(method_call);
+
+ return _dbus_message_new_error(hdr->version, reply_serial,
l_dbus_message_get_sender(method_call),
name, str);
}
diff --git a/ell/dbus.c b/ell/dbus.c
index 236c35a..2c04ec9 100644
--- a/ell/dbus.c
+++ b/ell/dbus.c
@@ -313,6 +313,16 @@ static uint32_t send_message(struct l_dbus *dbus, bool priority,
void *user_data, l_dbus_destroy_func_t destroy)
{
struct message_callback *callback;
+ enum dbus_message_type type;
+
+ type = _dbus_message_get_type(message);
+
+ if ((type == DBUS_MESSAGE_TYPE_METHOD_RETURN ||
+ type == DBUS_MESSAGE_TYPE_ERROR) &&
+ _dbus_message_get_reply_serial(message) == 0) {
+ l_dbus_message_unref(message);
+ return 0;
+ }
callback = l_new(struct message_callback, 1);
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] dbus: Don't send replies to messages with no reply flag
2016-11-09 10:22 [PATCH] dbus: Don't send replies to messages with no reply flag Andrew Zaborowski
@ 2016-11-09 20:16 ` Denis Kenzior
0 siblings, 0 replies; 3+ messages in thread
From: Denis Kenzior @ 2016-11-09 20:16 UTC (permalink / raw)
To: ell
[-- Attachment #1: Type: text/plain, Size: 697 bytes --]
Hi Andrew,
On 11/09/2016 04:22 AM, Andrew Zaborowski wrote:
> Kdbus doesn't store the cookies for messages that have the no reply flag
> and throws error when a reply is sent with reply_cookie that it doesn't
> know. It's not fatal, but we save some cycles by not sending the message
> with both dbus versions.
>
> We mark those replies with reply_serial == 0, rather than setting a
> "discard" flag on the message, because the method call's serial is
> effectively an invalid reply_serial value.
> ---
> ell/dbus-message.c | 10 +++++++---
> ell/dbus.c | 10 ++++++++++
> 2 files changed, 17 insertions(+), 3 deletions(-)
>
Applied, thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-11-09 20:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-09 10:22 [PATCH] dbus: Don't send replies to messages with no reply flag Andrew Zaborowski
2016-11-09 20:16 ` Denis Kenzior
-- strict thread matches above, loose matches on Subject: below --
2016-04-18 14:31 [PATCH 1/2] dbus: Add private _dbus_message_new_error Andrew Zaborowski
2016-04-18 14:31 ` [PATCH] dbus: Don't send replies to messages with no reply flag Andrew Zaborowski
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.