All of lore.kernel.org
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz@gmail.com>
To: ell@lists.01.org
Subject: Re: [PATCH 15/15] dbus: Don't send replies to messages with no reply flag.
Date: Thu, 24 Mar 2016 13:12:51 -0500	[thread overview]
Message-ID: <56F42E23.6090300@gmail.com> (raw)
In-Reply-To: <1458598224-29325-15-git-send-email-andrew.zaborowski@intel.com>

[-- Attachment #1: Type: text/plain, Size: 4314 bytes --]

Hi Andrew,

On 03/21/2016 05:10 PM, 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 also save some cycles by not sending the
> message.  A further change could be made to not even let users create a
> message as a return from a method call but that may be confusing.
> ---
>   ell/dbus-message.c | 32 +++++++++++++++++++++++++++-----
>   ell/dbus-private.h |  1 +
>   ell/dbus.c         |  5 +++++
>   3 files changed, 33 insertions(+), 5 deletions(-)
>
> diff --git a/ell/dbus-message.c b/ell/dbus-message.c
> index a7c9699..5ecac8d 100644
> --- a/ell/dbus-message.c
> +++ b/ell/dbus-message.c
> @@ -43,6 +43,7 @@
>
>   #define DBUS_MESSAGE_FLAG_NO_REPLY_EXPECTED	0x01
>   #define DBUS_MESSAGE_FLAG_NO_AUTO_START		0x02
> +#define DBUS_MESSAGE_FLAG_DISCARD		0x04

No, you're over-riding the ALLOW_INTERACTIVE_AUTHORIZATION flag.
>
>   #define DBUS_MESSAGE_FIELD_PATH		1
>   #define DBUS_MESSAGE_FIELD_INTERFACE	2
> @@ -185,6 +186,22 @@ LIB_EXPORT bool l_dbus_message_get_no_autostart(struct l_dbus_message *msg)
>
>   }
>
> +bool _dbus_message_get_discard(struct l_dbus_message *msg)
> +{
> +	struct dbus_header *hdr;
> +
> +	if (unlikely(!msg))
> +		return false;
> +
> +	hdr = msg->header;
> +
> +	if (hdr->flags & DBUS_MESSAGE_FLAG_DISCARD)
> +		return true;

No, please don't do it this way.  hdr gets sent over the wire.  We need 
to store this flag locally.  Lets just add

bool discard : 1;

to struct l_dbus_message

> +
> +	return false;
> +

Spurious whitespace

> +}
> +
>   static struct l_dbus_message *message_new_common(uint8_t type, uint8_t flags,
>   						uint8_t version)
>   {
> @@ -285,10 +302,13 @@ LIB_EXPORT struct l_dbus_message *l_dbus_message_new_method_return(
>   	struct l_dbus_message *message;
>   	struct dbus_header *hdr = method_call->header;
>   	const char *sender;
> +	uint8_t flags = DBUS_MESSAGE_FLAG_NO_REPLY_EXPECTED;
> +
> +	if (l_dbus_message_get_no_reply(method_call))
> +		flags |= DBUS_MESSAGE_FLAG_DISCARD;
>
>   	message = message_new_common(DBUS_MESSAGE_TYPE_METHOD_RETURN,
> -					DBUS_MESSAGE_FLAG_NO_REPLY_EXPECTED,
> -					hdr->version);
> +					flags, hdr->version);

if (l_dbus_message_get_no_reply(method_call))
	message->discard = true;

>
>   	message->reply_serial = hdr->serial;
>
> @@ -308,14 +328,16 @@ LIB_EXPORT struct l_dbus_message *l_dbus_message_new_error_valist(
>   	struct l_dbus_message *reply;
>   	struct dbus_header *hdr = method_call->header;
>   	const char *sender;
> +	uint8_t flags = DBUS_MESSAGE_FLAG_NO_REPLY_EXPECTED;
>
>   	if (!_dbus_valid_interface(name))
>   		return NULL;
>
> +	if (l_dbus_message_get_no_reply(method_call))
> +		flags |= DBUS_MESSAGE_FLAG_DISCARD;
> +
>   	vsnprintf(str, sizeof(str), format, args);
> -	reply = message_new_common(DBUS_MESSAGE_TYPE_ERROR,
> -					DBUS_MESSAGE_FLAG_NO_REPLY_EXPECTED,
> -					hdr->version);
> +	reply = message_new_common(DBUS_MESSAGE_TYPE_ERROR, flags, hdr->version);
>
>   	reply->reply_serial = hdr->serial;
>
> diff --git a/ell/dbus-private.h b/ell/dbus-private.h
> index 0ae4c69..3b40fea 100644
> --- a/ell/dbus-private.h
> +++ b/ell/dbus-private.h
> @@ -108,6 +108,7 @@ void *_dbus_message_get_header(struct l_dbus_message *msg, size_t *out_size);
>   void _dbus_message_set_serial(struct l_dbus_message *msg, uint32_t serial);
>   uint32_t _dbus_message_get_serial(struct l_dbus_message *msg);
>   uint32_t _dbus_message_get_reply_serial(struct l_dbus_message *message);
> +bool _dbus_message_get_discard(struct l_dbus_message *msg);
>
>   void _dbus_message_set_sender(struct l_dbus_message *message,
>   					const char *sender);
> diff --git a/ell/dbus.c b/ell/dbus.c
> index b9864bd..d976496 100644
> --- a/ell/dbus.c
> +++ b/ell/dbus.c
> @@ -1323,6 +1323,11 @@ LIB_EXPORT uint32_t l_dbus_send(struct l_dbus *dbus,
>   	if (unlikely(!dbus || !message))
>   		return 0;
>
> +	if (_dbus_message_get_discard(message)) {
> +		l_dbus_message_unref(message);
> +		return 0;
> +	}
> +
>   	return send_message(dbus, false, message, NULL, NULL, NULL);
>   }
>
>

Regards,
-Denis

  reply	other threads:[~2016-03-24 18:12 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-21 22:10 [PATCH 01/15] dbus: Add _dbus1_message_iter_skip_entry Andrew Zaborowski
2016-03-21 22:10 ` [PATCH 02/15] gvariant: Add _gvariant_iter_skip_entry Andrew Zaborowski
2016-03-24 14:35   ` Denis Kenzior
2016-03-21 22:10 ` [PATCH 03/15] dbus: Add _dbus_message_get_nth_string_argument Andrew Zaborowski
2016-03-24 14:35   ` Denis Kenzior
2016-03-21 22:10 ` [PATCH 04/15] dbus: Support 2+ arguments in l_dbus_message_get_error Andrew Zaborowski
2016-03-24 14:36   ` Denis Kenzior
2016-03-21 22:10 ` [PATCH 05/15] dbus: Fix _dbus_kernel_calculate_bloom for multiple arguments Andrew Zaborowski
2016-03-24 14:39   ` Denis Kenzior
2016-03-21 22:10 ` [PATCH 06/15] dbus: Add message filter logic in dbus-filter.c Andrew Zaborowski
2016-03-24 16:36   ` Denis Kenzior
2016-03-21 22:10 ` [PATCH 07/15] unit: Add dbus message filter tests Andrew Zaborowski
2016-03-24 16:37   ` Denis Kenzior
2016-03-21 22:10 ` [PATCH 08/15] dbus-filter: Name owner change tracking support Andrew Zaborowski
2016-03-24 17:28   ` Denis Kenzior
2016-03-21 22:10 ` [PATCH 09/15] dbus: Classic dbus filter_ops implementation Andrew Zaborowski
2016-03-24 17:41   ` Denis Kenzior
2016-03-25 23:30     ` Andrzej Zaborowski
2016-03-26  2:37       ` Denis Kenzior
2016-03-21 22:10 ` [PATCH 10/15] dbus: kdbus " Andrew Zaborowski
2016-03-24 17:51   ` Denis Kenzior
2016-03-21 22:10 ` [PATCH 11/15] linux: Update kdbus.h to current github version Andrew Zaborowski
2016-03-24 17:52   ` Denis Kenzior
2016-03-21 22:10 ` [PATCH 12/15] dbus-kernel: Update kdbus API usage to current version Andrew Zaborowski
2016-03-24 17:52   ` Denis Kenzior
2016-03-21 22:10 ` [PATCH 13/15] dbus: Add message filter public API Andrew Zaborowski
2016-03-24 18:04   ` Denis Kenzior
2016-03-25 23:45     ` Andrzej Zaborowski
2016-03-26  2:42       ` Denis Kenzior
2016-03-26 15:22         ` Andrzej Zaborowski
2016-03-26 21:53           ` Denis Kenzior
2016-03-27  3:48             ` Andrzej Zaborowski
2016-03-21 22:10 ` [PATCH 14/15] unit: Use the message filter API in dbus tests Andrew Zaborowski
2016-03-24 18:06   ` Denis Kenzior
2016-03-21 22:10 ` [PATCH 15/15] dbus: Don't send replies to messages with no reply flag Andrew Zaborowski
2016-03-24 18:12   ` Denis Kenzior [this message]
2016-03-25 23:52     ` Andrzej Zaborowski
2016-03-24 14:35 ` [PATCH 01/15] dbus: Add _dbus1_message_iter_skip_entry Denis Kenzior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56F42E23.6090300@gmail.com \
    --to=denkenz@gmail.com \
    --cc=ell@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.