Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932252AbbDMOO0 (ORCPT ); Mon, 13 Apr 2015 10:14:26 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:52233 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752946AbbDMOOX (ORCPT ); Mon, 13 Apr 2015 10:14:23 -0400 X-AuditID: cbfee61b-f79536d000000f1f-84-552bcf3d9a19 From: Lukasz Skalski To: gregkh@linuxfoundation.org, daniel@zonque.org, dh.herrmann@gmail.com, tixxdz@opendz.org Cc: linux-kernel@vger.kernel.org, Lukasz Skalski Subject: [PATCH] kdbus: do not append the same connection to the queue twice Date: Mon, 13 Apr 2015 16:14:06 +0200 Message-id: <1428934446-32364-1-git-send-email-l.skalski@samsung.com> X-Mailer: git-send-email 1.9.3 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrFJMWRmVeSWpSXmKPExsVy+t9jAV3b89qhBt97ZC2a/r5isZjXepTF onnxejaLOecamSwu75rDZrHy93Y2BzaPnbPusnvsn7uG3WPFryPsHn1bVjF6fN4k57F993KW ALYoLpuU1JzMstQifbsEroyll+cwFtzkrGjoe8DSwHiCvYuRk0NCwERi79+PzBC2mMSFe+vZ uhi5OIQEFjFKrJncyQzh/GSUuLXrGBNIFZuAjsSTk/fBbBGBWIkd9zsYuxg5OJgFPCQWrNIA MYUFfCRu3YoEqWARUJVY8fU+I4jNK+Aq8biplQ1il5xE77Y3zBMYuRcwMqxiFE0tSC4oTkrP NdIrTswtLs1L10vOz93ECA6RZ9I7GFc1WBxiFOBgVOLhvXBHK1SINbGsuDL3EKMEB7OSCO+j ndqhQrwpiZVVqUX58UWlOanFhxilOViUxHnn6MqFCgmkJ5akZqemFqQWwWSZODilGhiDzmc4 dq1NOMitM/f2RpY+D5Xm5NqWqJapr/ocOnvmM02+c2D+M/eS2XcNdv08uajmywmpG6U8wWun M953XrfvmK70tOBXMQ0SnzorO1i++HrP6jm4KOCXNv+X9yVPX691vR190vaYNh+P6vKb1paV ImcstgcVXHO9V7sprGb1rjmKmQeZ3H4rsRRnJBpqMRcVJwIAituC7g0CAAA= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1444 Lines: 47 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 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 -- 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/