Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp199497ybg; Mon, 8 Jun 2020 20:59:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxrQPiM5vjlWbJB4ETwGm8vmcs4h/M3Bosgq868Z1shnwS3Oa3FrVrjt3VinJfYEtv240ts X-Received: by 2002:a50:8307:: with SMTP id 7mr25475811edh.283.1591675195514; Mon, 08 Jun 2020 20:59:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591675195; cv=none; d=google.com; s=arc-20160816; b=JeCSIX0aJ2M715ehI4yoYkqkGdesA6IIk2KBBcXRBeQEPqXI6ArQtpA34kC3Y/WvsR +l38d8uRMmT8l68nA4l742sGYG/5wxMwi1OjDc6ld3D0zP/iKtVbmnGthRZ1IlActm27 Oa18lpMFewvAmfjCpnjf+Bn5elOcaB89YqfhsXWPfnfVQ1oTS09IlRS5Fhz3OWa4zjSM 92L78RlLftSiy6vBAQSsHgt9JzoqJU6lH2CglB/cTClYUarOyb/F+dpsuzKTDZGd+2+Q 7dJQyo7uE6BCe/LqgKgRQo5DlWiMskcd/bxOAjKynW2BIXPQ/MlJuACFOna+ax044CW6 caPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=6MNFMb8Yq/3HfLDnPIDzzpObr8jnGOY1JXpKB8KRd1A=; b=bV0EADqf+dB10a5w/+zbnNtanoaOSq5M0hrqXa1zxzDGxD9iaNtTTFntsRz9xDADdD 60zFevix3qUgygTbtBMDWHOaFWUHf7QgMRE2OKHeikac601KgVDfYUy22hZJzs5GtJ15 UuszsQQuL9QVBggq6Nabt+svn+VRe0B1GiOYVYllyt+9O0Z2vPqz392WwxxDfUXl1hoJ AuE1HtCBkODdpHEp0lLDsbMg+JhO5fOKE+LR6pVLs6FX3jSb/WplJUzO6j+7jHSudGhT EPIgX0XSyqziWKd09PQVXupqPnXS2HHZ+bz1Gf8OFYl+48hVE8K0JjVToUBG6EV1F7Nj H/kQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dc9si9905840ejb.98.2020.06.08.20.59.21; Mon, 08 Jun 2020 20:59:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726937AbgFID7P (ORCPT + 99 others); Mon, 8 Jun 2020 23:59:15 -0400 Received: from mga12.intel.com ([192.55.52.136]:17243 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726924AbgFID7N (ORCPT ); Mon, 8 Jun 2020 23:59:13 -0400 IronPort-SDR: /2ytIDYVn3Lq01XfrtG0f946HX+BPUifouj6UqRjGHbCfN4geh8xWgQfBzK+U5F6XGb8jB9/Hc C2y3EehWLNcA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jun 2020 20:59:13 -0700 IronPort-SDR: rXmqofCt1dtmweZyFkzgI4o+5Sj2yjXi1wIkOpIJT2tQL3leLrjPJN0khT2MGJtU6XhjKD/K0y HupoI4BnlmUA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,490,1583222400"; d="scan'208";a="274461153" Received: from vrsuryad-mobl1.amr.corp.intel.com (HELO ingas-nuc1.sea.intel.com) ([10.255.228.38]) by orsmga006.jf.intel.com with ESMTP; 08 Jun 2020 20:59:13 -0700 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, przemyslaw.fierek@silvair.com, Inga Stotland Subject: [PATCH BlueZ 3/4] mesh: Add timeout to a get managed objects call Date: Mon, 8 Jun 2020 20:59:08 -0700 Message-Id: <20200609035909.51061-4-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200609035909.51061-1-inga.stotland@intel.com> References: <20200609035909.51061-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Switch to using dbus_send_with_timeout when making a request to get managed objects from an application. --- mesh/node.c | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/mesh/node.c b/mesh/node.c index d1d4da23d..7ec06437b 100644 --- a/mesh/node.c +++ b/mesh/node.c @@ -1459,7 +1459,7 @@ static void get_managed_objects_cb(struct l_dbus_message *msg, void *user_data) struct keyring_net_key net_key; uint8_t dev_key[16]; - if (l_dbus_message_is_error(msg)) { + if (!msg || l_dbus_message_is_error(msg)) { l_error("Failed to get app's dbus objects"); goto fail; } @@ -1616,8 +1616,7 @@ static void get_managed_objects_cb(struct l_dbus_message *msg, void *user_data) fail: /* Handle failed requests */ - if (node) - node_remove(node); + node_remove(node); if (req->type == REQUEST_TYPE_JOIN) req->join_ready_cb(NULL, NULL); @@ -1628,6 +1627,20 @@ fail: l_free(req->import); } +static void send_managed_objects_request(const char *destination, + const char *path, + struct managed_obj_request *req) +{ + struct l_dbus_message *msg; + + msg = l_dbus_message_new_method_call(dbus_get_bus(), destination, path, + L_DBUS_INTERFACE_OBJECT_MANAGER, + "GetManagedObjects"); + l_dbus_message_set_arguments(msg, ""); + dbus_send_with_timeout(dbus_get_bus(), msg, get_managed_objects_cb, + req, l_free, DEFAULT_DBUS_TIMEOUT); +} + /* Establish relationship between application and mesh node */ void node_attach(const char *app_root, const char *sender, uint64_t token, node_ready_func_t cb, void *user_data) @@ -1661,11 +1674,7 @@ void node_attach(const char *app_root, const char *sender, uint64_t token, req->attach = node; req->type = REQUEST_TYPE_ATTACH; - l_dbus_method_call(dbus_get_bus(), sender, app_root, - L_DBUS_INTERFACE_OBJECT_MANAGER, - "GetManagedObjects", NULL, - get_managed_objects_cb, - req, l_free); + send_managed_objects_request(sender, app_root, req); } /* Create a temporary pre-provisioned node */ @@ -1681,11 +1690,7 @@ void node_join(const char *app_root, const char *sender, const uint8_t *uuid, req->join_ready_cb = cb; req->type = REQUEST_TYPE_JOIN; - l_dbus_method_call(dbus_get_bus(), sender, app_root, - L_DBUS_INTERFACE_OBJECT_MANAGER, - "GetManagedObjects", NULL, - get_managed_objects_cb, - req, l_free); + send_managed_objects_request(sender, app_root, req); } void node_import(const char *app_root, const char *sender, const uint8_t *uuid, @@ -1715,11 +1720,7 @@ void node_import(const char *app_root, const char *sender, const uint8_t *uuid, req->type = REQUEST_TYPE_IMPORT; - l_dbus_method_call(dbus_get_bus(), sender, app_root, - L_DBUS_INTERFACE_OBJECT_MANAGER, - "GetManagedObjects", NULL, - get_managed_objects_cb, - req, l_free); + send_managed_objects_request(sender, app_root, req); } void node_create(const char *app_root, const char *sender, const uint8_t *uuid, @@ -1735,11 +1736,7 @@ void node_create(const char *app_root, const char *sender, const uint8_t *uuid, req->pending_msg = user_data; req->type = REQUEST_TYPE_CREATE; - l_dbus_method_call(dbus_get_bus(), sender, app_root, - L_DBUS_INTERFACE_OBJECT_MANAGER, - "GetManagedObjects", NULL, - get_managed_objects_cb, - req, l_free); + send_managed_objects_request(sender, app_root, req); } static void build_element_config(void *a, void *b) -- 2.26.2