lkml.org 
[lkml]   [2015]   [Apr]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] kdbus: do not append the same connection to the queue twice
Date
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


\
 
 \ /
  Last update: 2015-04-13 16:41    [W:0.052 / U:5.248 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site