Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp229578lqt; Thu, 18 Apr 2024 13:18:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWJJaje4QI1HuwxrylaiusfE6CwQyLZPcCb3V1ASFyKL7N8XBvaxs//6+rWEHg5z7L0F5LRKJ199r5Wi99kIl0FJwKm9rNwkWQT1qiiJA== X-Google-Smtp-Source: AGHT+IHUM5BCxLgJXc3U3dnWISyjPgwYd3OsUNVIHbu+vuAzZBhrn28W2AcfmLw2PF60Bs1hcgvT X-Received: by 2002:a17:90a:9e7:b0:2ac:2b02:e167 with SMTP id 94-20020a17090a09e700b002ac2b02e167mr232368pjo.37.1713471533841; Thu, 18 Apr 2024 13:18:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713471533; cv=pass; d=google.com; s=arc-20160816; b=dNCgF+vO1mfRn/WyAqlAToWKTw4btylYtaZxeb8I/P91f81MytrFOlyyKBKKeETmtX UZQCIfaYCjF+H9Jn4si6icLsk6eHoYLY5Ex8g0JGpOZrCwrKvcpkQxdP3+w+cft0nR2j tBCsD1hy8x9N87h1mAOOXkQLzeUdRdztTT619CFXdPVDtmAbuqTu5li6248xpqde89cl wB24ckvWNbnVLok3DHM05vT2di3vepOYGVqQJuFEnElDkaMp6mBAz/QbtBQhTDmIUGzB PeYdrJGwf2GIuUucg0J04YAIVe4JJwB9hgQi9/gYSjGEpspJsZjWol7VEiENs1GRnFXm vR+Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:to:from :dkim-signature; bh=ZhCN9k/iYBz1KZ4MDFKNAVXFgSDdmQhmySicXxZ2jIQ=; fh=4lGQI6056MBa4/oovMyIYaKLn+Wz/24RGvUivMmQP8E=; b=yEVstSu+lU/yUb7Vb3HcRPhEBQW9RF6WrrLJ0xEjYyFm2D6XJV670O/APA+xhH/H1e 3L9Z3fwzuQLRlwQfdRxVdLsiGyK5S0wGGp6OYemBKcrCglCc7FUd3COxPHWVSEtrfFyl XXkeVIw+206hlbnGdFasG2U1FAtu9psv6tHfFJDWVLvwqXa6ZdXeJ3AXSSzOIp1n21+o RhJzgNe3X4qZGam/wnEGIIed0A3J/MrwMoxiyPrlSlpJ29o2dnm+2zRryN2hJgozmiII LfBeUwUeaJA80sapQQKILNyDppz7l8LQjyS+WfkMJdW3QgBfzrXSviF33e3QJIGkBvL3 hrug==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Fxcow7vP; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-bluetooth+bounces-3738-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-3738-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id l2-20020a17090ad10200b002a85806f6e1si2051896pju.172.2024.04.18.13.18.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 13:18:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-3738-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Fxcow7vP; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-bluetooth+bounces-3738-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-3738-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id AC8D8B27C1C for ; Thu, 18 Apr 2024 19:51:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6E9C91A0AE1; Thu, 18 Apr 2024 19:47:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Fxcow7vP" X-Original-To: linux-bluetooth@vger.kernel.org Received: from mail-ua1-f49.google.com (mail-ua1-f49.google.com [209.85.222.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 76BF6181B90 for ; Thu, 18 Apr 2024 19:47:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713469648; cv=none; b=gyckwycdobjUSzFg8KABDhEIwdY/ANVIPU0YvENI5OH8A0Orzax4Xv3pYFr+OXWb1M+QaAiDhL4umcG7sYOzkq9WgmC3hJzj/xz9nrMN1I/dVZffXZAkKUIr2sdI5amonHCgnwVPoSC8gi/vEFmneW4Fx0i20ZqWvLcXyCVk7dg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713469648; c=relaxed/simple; bh=QS7/7E8PZ5Vd8XOhb5KdSEXRpRo3qg8eq5R1LuE97uM=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=Agnr/6CMRMzEcwz5iIvY8hO5sbK7HxevKvYVpM6IYpALPPbfsTRx8yRQrgSCEbNi6m9Fg37dozEdCUP4LOwITix0gnfqwDmpUpidO/zNAyeWwbmh3EjsP7Y20pZGVnbYvNsCTUApvLLH+NuR0iCu4WrqR7UfKTVxjeGDg06wrjg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Fxcow7vP; arc=none smtp.client-ip=209.85.222.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ua1-f49.google.com with SMTP id a1e0cc1a2514c-7eb9cb7b657so287000241.1 for ; Thu, 18 Apr 2024 12:47:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713469646; x=1714074446; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=ZhCN9k/iYBz1KZ4MDFKNAVXFgSDdmQhmySicXxZ2jIQ=; b=Fxcow7vPUS1NYi48kpQQa/ldcR5JFnNoHnlV+zgzW+abNaYPoB9poaytPiI1n+SAMt bywKGfDMmsTsNliFg9vwMm6Hm5z1iMBJCs7I0P+h8z4ZBKgv9MSrEqVGYkt37KxAY2SX MvyNo0mksUyVms5sF52YDw5/UAqfaGvaX4zgyGKzk+rB/rkCxVUro+quq2Qk3Mt/VgWv Wa1JJwttAV38YV915/HsNrT9iiQPYwZTr4w1WUtZhbZmIlPdqkhmQFuy8Isl0SFf+R7l QFJ6aynmr3s6jKuAsB3Bl35MapvFjFpBmiakxqY0C54xfeTSlK55RM5f8EqcliCOsTzl slSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713469646; x=1714074446; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ZhCN9k/iYBz1KZ4MDFKNAVXFgSDdmQhmySicXxZ2jIQ=; b=IuzbVTFhNDLeGN5KfRSOVl4rZFcCrQpj6v5eh5NkI89Q/t4FE8QG7/ly+z2HKzmfWE Po0JKJ549D/5OWerLNqlq5vDf20/Mzhz5u9vWXXo45McFANEO13s/nVgKYKXLJ9MdujE d0joATN/vTMarkwy2VzAjJrgVeD4GoOz1/VP4sLehfpnBgi6rvxa8e00R3rRuR3cLKlS oZZ0sV+J1UrbyL/PjO0Nb0hCL6NED0VCgFbXacfqk+6xTojdhxyFZn2HT3dfXPDzgf+/ 14k4FLkGvf3lGeR1PIfOptjSPKHC9rYSBzFFZZoynim+ilt4Xss0ly7cRDEF1uRG//hc VO/g== X-Gm-Message-State: AOJu0YxW9fO8ZsQjNo7WndwT9fDQ1LeTO0Sri+RtrvU7P8nytnfMN+XY gbSnXIYU6aheuDpqKdpDrY2holHA2lsATTOAShnX8Wb1Aws1e5XDIZxjVA== X-Received: by 2002:a05:6102:2041:b0:47a:4138:dc1e with SMTP id q1-20020a056102204100b0047a4138dc1emr4220421vsr.20.1713469645605; Thu, 18 Apr 2024 12:47:25 -0700 (PDT) Received: from lvondent-mobl4.. ([107.146.107.67]) by smtp.gmail.com with ESMTPSA id ij22-20020a0561025e9600b00479f9f9da85sm306191vsb.18.2024.04.18.12.47.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 12:47:24 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v1] gatt-database: Fix sending notification to all devices Date: Thu, 18 Apr 2024 15:47:23 -0400 Message-ID: <20240418194723.1440686-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.44.0 Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Luiz Augusto von Dentz If notifications where setup with GATT application that implements AcquireNotify the code will attempt to setup a dedicate fd/io for each device so when receiving a notification over the fd/io it is only meant to be send to the device only. Fixes: https://github.com/bluez/bluez/issues/820 --- src/gatt-database.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/gatt-database.c b/src/gatt-database.c index 6c11027a79ed..7ca2f94222c6 100644 --- a/src/gatt-database.c +++ b/src/gatt-database.c @@ -112,6 +112,7 @@ struct external_profile { struct client_io { struct bt_att *att; + struct external_chrc *chrc; unsigned int disconn_id; struct io *io; }; @@ -2588,7 +2589,8 @@ static bool sock_hup(struct io *io, void *user_data) static bool sock_io_read(struct io *io, void *user_data) { - struct external_chrc *chrc = user_data; + struct client_io *client = user_data; + struct external_chrc *chrc = client->chrc; uint8_t buf[512]; int fd = io_get_fd(io); ssize_t bytes_read; @@ -2597,12 +2599,8 @@ static bool sock_io_read(struct io *io, void *user_data) if (bytes_read <= 0) return false; - send_notification_to_devices(chrc->service->app->database, - gatt_db_attribute_get_handle(chrc->attrib), - buf, bytes_read, - gatt_db_attribute_get_handle(chrc->ccc), - conf_cb, - chrc->proxy); + gatt_notify_cb(chrc->attrib, chrc->ccc, buf, bytes_read, client->att, + client->chrc->service->app->database); return true; } @@ -2652,6 +2650,7 @@ client_io_new(struct external_chrc *chrc, int fd, struct bt_att *att) client = new0(struct client_io, 1); client->att = bt_att_ref(att); + client->chrc = chrc; client->disconn_id = bt_att_register_disconnect(att, att_disconnect_cb, client, NULL); client->io = sock_io_new(fd, chrc); @@ -2809,7 +2808,7 @@ client_notify_io_get(struct external_chrc *chrc, int fd, struct bt_att *att) client = client_io_new(chrc, fd, att); - io_set_read_handler(client->io, sock_io_read, chrc, NULL); + io_set_read_handler(client->io, sock_io_read, client, NULL); if (!chrc->notify_ios) chrc->notify_ios = queue_new(); -- 2.44.0