All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kdbus: do not append the same connection to the queue twice
@ 2015-04-13 14:14 Lukasz Skalski
  2015-04-13 21:48 ` Sergei Zviagintsev
  0 siblings, 1 reply; 3+ messages in thread
From: Lukasz Skalski @ 2015-04-13 14:14 UTC (permalink / raw)
  To: gregkh, daniel, dh.herrmann, tixxdz; +Cc: linux-kernel, Lukasz Skalski

As it was discussed on systemd ML [1], the same connection should be
queued up only once for a given well-known name.

[1] http://lists.freedesktop.org/archives/systemd-devel/2015-April/030494.html

Signed-off-by: Lukasz Skalski <l.skalski@samsung.com>

diff --git a/ipc/kdbus/names.c b/ipc/kdbus/names.c
index 657008e..a546a84 100644
--- a/ipc/kdbus/names.c
+++ b/ipc/kdbus/names.c
@@ -353,10 +353,23 @@ int kdbus_name_acquire(struct kdbus_name_registry *reg,
 	} else if (flags & KDBUS_NAME_QUEUE) {
 		/* add to waiting-queue of the name */
 
-		ret = kdbus_name_pending_new(e, conn, flags);
-		if (ret >= 0)
-			/* tell the caller that we queued it */
-			rflags |= KDBUS_NAME_IN_QUEUE;
+		struct kdbus_name_pending *p;
+		bool in_queue = false;
+
+		list_for_each_entry(p, &e->queue, name_entry) {
+			if (p->conn == conn) {
+				/* connection is already queued */
+				rflags |= KDBUS_NAME_IN_QUEUE;
+				in_queue = true;
+			}
+		}
+
+		if (!in_queue) {
+			ret = kdbus_name_pending_new(e, conn, flags);
+			if (ret >= 0)
+				/* tell the caller that we queued it */
+				rflags |= KDBUS_NAME_IN_QUEUE;
+		}
 	} else {
 		/* the name is busy, return a failure */
 		ret = -EEXIST;
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] kdbus: do not append the same connection to the queue twice
  2015-04-13 14:14 [PATCH] kdbus: do not append the same connection to the queue twice Lukasz Skalski
@ 2015-04-13 21:48 ` Sergei Zviagintsev
  2015-04-14  8:27   ` Lukasz Skalski
  0 siblings, 1 reply; 3+ messages in thread
From: Sergei Zviagintsev @ 2015-04-13 21:48 UTC (permalink / raw)
  To: Lukasz Skalski; +Cc: gregkh, daniel, dh.herrmann, tixxdz, linux-kernel

Hi Lukasz,

On Mon, Apr 13, 2015 at 04:14:06PM +0200, Lukasz Skalski wrote:
> As it was discussed on systemd ML [1], the same connection should be
> queued up only once for a given well-known name.
> 
> [1] http://lists.freedesktop.org/archives/systemd-devel/2015-April/030494.html
> 
> Signed-off-by: Lukasz Skalski <l.skalski@samsung.com>
> 
> diff --git a/ipc/kdbus/names.c b/ipc/kdbus/names.c
> index 657008e..a546a84 100644
> --- a/ipc/kdbus/names.c
> +++ b/ipc/kdbus/names.c
> @@ -353,10 +353,23 @@ int kdbus_name_acquire(struct kdbus_name_registry *reg,
>  	} else if (flags & KDBUS_NAME_QUEUE) {
>  		/* add to waiting-queue of the name */
>  
> -		ret = kdbus_name_pending_new(e, conn, flags);
> -		if (ret >= 0)
> -			/* tell the caller that we queued it */
> -			rflags |= KDBUS_NAME_IN_QUEUE;
> +		struct kdbus_name_pending *p;
> +		bool in_queue = false;
> +
> +		list_for_each_entry(p, &e->queue, name_entry) {
> +			if (p->conn == conn) {
> +				/* connection is already queued */
> +				rflags |= KDBUS_NAME_IN_QUEUE;
> +				in_queue = true;

break here?

> +			}
> +		}
> +
> +		if (!in_queue) {
> +			ret = kdbus_name_pending_new(e, conn, flags);
> +			if (ret >= 0)
> +				/* tell the caller that we queued it */
> +				rflags |= KDBUS_NAME_IN_QUEUE;
> +		}
>  	} else {
>  		/* the name is busy, return a failure */
>  		ret = -EEXIST;
> -- 
> 1.9.3
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] kdbus: do not append the same connection to the queue twice
  2015-04-13 21:48 ` Sergei Zviagintsev
@ 2015-04-14  8:27   ` Lukasz Skalski
  0 siblings, 0 replies; 3+ messages in thread
From: Lukasz Skalski @ 2015-04-14  8:27 UTC (permalink / raw)
  To: Sergei Zviagintsev; +Cc: gregkh, daniel, dh.herrmann, tixxdz, linux-kernel


On 04/13/2015 11:48 PM, Sergei Zviagintsev wrote:
> Hi Lukasz,
> 

Hi,

> On Mon, Apr 13, 2015 at 04:14:06PM +0200, Lukasz Skalski wrote:
>> As it was discussed on systemd ML [1], the same connection should be
>> queued up only once for a given well-known name.
>>
>> [1] http://lists.freedesktop.org/archives/systemd-devel/2015-April/030494.html
>>
>> Signed-off-by: Lukasz Skalski <l.skalski@samsung.com>
>>
>> diff --git a/ipc/kdbus/names.c b/ipc/kdbus/names.c
>> index 657008e..a546a84 100644
>> --- a/ipc/kdbus/names.c
>> +++ b/ipc/kdbus/names.c
>> @@ -353,10 +353,23 @@ int kdbus_name_acquire(struct kdbus_name_registry *reg,
>>  	} else if (flags & KDBUS_NAME_QUEUE) {
>>  		/* add to waiting-queue of the name */
>>  
>> -		ret = kdbus_name_pending_new(e, conn, flags);
>> -		if (ret >= 0)
>> -			/* tell the caller that we queued it */
>> -			rflags |= KDBUS_NAME_IN_QUEUE;
>> +		struct kdbus_name_pending *p;
>> +		bool in_queue = false;
>> +
>> +		list_for_each_entry(p, &e->queue, name_entry) {
>> +			if (p->conn == conn) {
>> +				/* connection is already queued */
>> +				rflags |= KDBUS_NAME_IN_QUEUE;
>> +				in_queue = true;
> 
> break here?
> 

Right. I've just sent v2. Thanks!

>> +			}
>> +		}
>> +
>> +		if (!in_queue) {
>> +			ret = kdbus_name_pending_new(e, conn, flags);
>> +			if (ret >= 0)
>> +				/* tell the caller that we queued it */
>> +				rflags |= KDBUS_NAME_IN_QUEUE;
>> +		}
>>  	} else {
>>  		/* the name is busy, return a failure */
>>  		ret = -EEXIST;
>> -- 
>> 1.9.3
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at  http://www.tux.org/lkml/
> 

Cheers,
-- 
Lukasz Skalski
Samsung R&D Institute Poland
Samsung Electronics
l.skalski@samsung.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-04-14  8:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-13 14:14 [PATCH] kdbus: do not append the same connection to the queue twice Lukasz Skalski
2015-04-13 21:48 ` Sergei Zviagintsev
2015-04-14  8:27   ` Lukasz Skalski

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.