Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp295811ybt; Wed, 17 Jun 2020 00:50:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJytkV6DgwJyYFm3FqVp1DxrvaHlJaSeW4qS6k91/8G2Hztu7LFNC7Erq4wGkidvu3igUb/K X-Received: by 2002:a17:906:6890:: with SMTP id n16mr6207484ejr.553.1592380238118; Wed, 17 Jun 2020 00:50:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592380238; cv=none; d=google.com; s=arc-20160816; b=IvTGy4pL1mC+JQlr/wnKAmv+TS3QAsql4d6Afzax66zzr1kCLJJ2a3/usKP3Wc6qiW nsLvesKB9bdxMZOK2/TOiF6dTq82T/UnYtoueGX6s+kEXklO0eqbAMTC45xmOHG6+JC3 F0BLeH85e1rkPo/TarvQgnR+tfp7cnPhPSJk243ow+j57HYJE+msLT18k1L/LIayvGgd aDkVWCv1bxl+tO0PKKkbdWxMaZJsXC6hurXxImnDBKnKA7kdLmonvPRlDoiyNWC4BXvW fp7b8Hw0T6pIv29SAxTqiszepVPG7al0+SFFle8Rebjhn7XWpf/U/Rg8ZKzvRPKNYrS2 krpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:mail-followup-to:message-id:subject:cc:to:from:date :dkim-signature; bh=IwFpNEPNq9wxv3xJ7gG8eHJ66U4NFq8U8PuusGH9/YQ=; b=oKRb639/vDmRrNnofhIK+uKXC3LRd1oFlyCTs12ZxoHHdZI+okzPGLiOwDGXcb6PYW DYd4F0wE+UHq+RYu2Y1KqmwmejMhXEGdsSMRb4fQnd+uTffxVJZD8qEQCCRSdfqDCBo9 PaGRVEYbUvUKd0+bfRX8CfkuDtPk5YWt3rM9J17BbbbgqBIriIaJdZTtoae45Gxoqnrx P+JjZsU3hfLkeZKt6kZwfP9v4RzvhuszNoEwzqEGYJEM0b3QdzrRYyQOcT5i39b4tEcv byQ/AYtXNikN3HHANWL/XD2+1FdenJFvQ/9JsUMBpfQZHbK37ctwjfPQslqrTYOIfY3o 9H1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@silvair-com.20150623.gappssmtp.com header.s=20150623 header.b=XOOIql9Q; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cb14si11890369edb.161.2020.06.17.00.50.02; Wed, 17 Jun 2020 00:50:38 -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; dkim=pass header.i=@silvair-com.20150623.gappssmtp.com header.s=20150623 header.b=XOOIql9Q; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725773AbgFQHt4 (ORCPT + 99 others); Wed, 17 Jun 2020 03:49:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725554AbgFQHtz (ORCPT ); Wed, 17 Jun 2020 03:49:55 -0400 Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AAEFC061573 for ; Wed, 17 Jun 2020 00:49:54 -0700 (PDT) Received: by mail-lj1-x244.google.com with SMTP id n24so1639697lji.10 for ; Wed, 17 Jun 2020 00:49:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silvair-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=IwFpNEPNq9wxv3xJ7gG8eHJ66U4NFq8U8PuusGH9/YQ=; b=XOOIql9QXrE51u0F/d1Gqy51CviKGQPs1i6JHSM/E/256c6OSeAnUEsNG/HCvILzsh hP/bxVTJoHrcgVOASHx8lxpdPQirF1WbyXUGyRuRP5EsK2Neai8J7jPGTntiaM/LNHlS wqZI1gwfvlimEqfxNxTS73RvTabMPQbeKGyLTsN0cFvD7lbZ50iYiJ8nfjrXpQBfH67V 8H65r8WylPLOMvLG5g3aaE4S8WA76+pik0+IaqwMR5k2RVyH5OOh6SPdh8HyQ6O9givn 96fkZOQzOjdJ/h6K2dj87R+F8MRidm2EXVlKVXbInFfWdPrKBbnwawGQkoZj3A5WNt7X LsoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=IwFpNEPNq9wxv3xJ7gG8eHJ66U4NFq8U8PuusGH9/YQ=; b=MhqnAB7BOGajluo3BdJpELUILPmxs92OxjPIrXyk98gfmfEshf7b2KwHRSaTmhqmiK drDmqt8TfTF2jvFrRan8Jf+e22uQ70WYK/jiLARIF0Av4tbLRcQAAHbnpbNZmZYDyH5f KEhM6A+arpzVfgUPG93HM7jBijRdbG7m7v9dV9UUJwY66XYWSRbWJe4XjMHCwXkEkbsd IWnshVFcXNk1iRRMe9J2YeAmzzR/3lzo6XGlDNdsT0yiIPQGNzoKIRKM5iCIUmSFhbl4 1gwwAeixCU+IRqFVBuZuBkKfj2VmTwPd5wt+L4ReC6iVzoM1GgV+CeL1YGWew9lYQakD 2SeQ== X-Gm-Message-State: AOAM531+445uxiscNaKT43qjDMtFcftI+H/XfxTO/X77T/nphhNyJM25 NtLasYE9TEKWkTm0BHu+jUWRNOGVIp4eYQ== X-Received: by 2002:a2e:1311:: with SMTP id 17mr3347715ljt.122.1592380192251; Wed, 17 Jun 2020 00:49:52 -0700 (PDT) Received: from mlowasrzechonek2133 ([217.153.94.18]) by smtp.gmail.com with ESMTPSA id l22sm4826539lji.120.2020.06.17.00.49.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2020 00:49:51 -0700 (PDT) Date: Wed, 17 Jun 2020 09:50:15 +0200 From: =?utf-8?Q?Micha=C5=82?= Lowas-Rzechonek To: Brian Gix Cc: linux-bluetooth@vger.kernel.org, inga.stotland@intel.com Subject: Re: [PATCH BlueZ v2] mesh: Add deferral of Attach() and Leave() if busy Message-ID: <20200617075015.4hntygf64dzz6fka@mlowasrzechonek2133> Mail-Followup-To: Brian Gix , linux-bluetooth@vger.kernel.org, inga.stotland@intel.com References: <20200616181436.50319-1-brian.gix@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200616181436.50319-1-brian.gix@intel.com> User-Agent: NeoMutt/20180716 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org On 06/16, Brian Gix wrote: > We require the successful return of JoinComplete() method before > handling subsequent Attach() or Leave() method calls. To simplify the > construction of Applications, we will accept one of these calls up to 1 > second prior to receiving the final return status of JoinComplete, > which tells us that the Application is ready to use the node. > > If the node is still not ready after the deferral, Attach and/or Leave > will fail. Nice, I think this solution is simpler than the patch I came up with. > --- > mesh/mesh.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++-- > 1 file changed, 52 insertions(+), 2 deletions(-) > > diff --git a/mesh/mesh.c b/mesh/mesh.c > index ab2393deb..bc170371d 100644 > --- a/mesh/mesh.c > +++ b/mesh/mesh.c > @@ -104,6 +104,10 @@ static struct l_queue *pending_queue; > > static const char *storage_dir; > > +/* Forward static decalrations */ > +static void def_attach(struct l_timeout *timeout, void *user_data); > +static void def_leave(struct l_timeout *timeout, void *user_data); > + > static bool simple_match(const void *a, const void *b) > { > return a == b; > @@ -634,12 +638,26 @@ static struct l_dbus_message *attach_call(struct l_dbus *dbus, > uint64_t token; > const char *app_path, *sender; > struct l_dbus_message *pending_msg; > + struct mesh_node *node; > > l_debug("Attach"); > > if (!l_dbus_message_get_arguments(msg, "ot", &app_path, &token)) > return dbus_error(msg, MESH_ERROR_INVALID_ARGS, NULL); > > + node = node_find_by_token(token); > + if (!node) > + return dbus_error(msg, MESH_ERROR_NOT_FOUND, "Attach failed"); > + > + if (node_is_busy(node)) { > + if (user_data) > + return dbus_error(msg, MESH_ERROR_BUSY, NULL); > + > + /* Try once more in 1 second */ > + l_timeout_create(1, def_attach, l_dbus_message_ref(msg), NULL); > + return NULL; > + } > + > sender = l_dbus_message_get_sender(msg); > > pending_msg = l_dbus_message_ref(msg); > @@ -650,6 +668,19 @@ static struct l_dbus_message *attach_call(struct l_dbus *dbus, > return NULL; > } > > +static void def_attach(struct l_timeout *timeout, void *user_data) > +{ > + struct l_dbus *dbus = dbus_get_bus(); > + struct l_dbus_message *msg = user_data; > + struct l_dbus_message *reply; > + > + l_timeout_remove(timeout); > + > + reply = attach_call(dbus, msg, (void *) true); Why not pass NULL as the 3rd argument? We register the interface with empty user data, so this would be an equivalent. > + l_dbus_send(dbus, reply); > + l_dbus_message_unref(msg); > +} > + > static struct l_dbus_message *leave_call(struct l_dbus *dbus, > struct l_dbus_message *msg, > void *user_data) > @@ -666,14 +697,33 @@ static struct l_dbus_message *leave_call(struct l_dbus *dbus, > if (!node) > return dbus_error(msg, MESH_ERROR_NOT_FOUND, NULL); > > - if (node_is_busy(node)) > - return dbus_error(msg, MESH_ERROR_BUSY, NULL); > + if (node_is_busy(node)) { > + if (user_data) > + return dbus_error(msg, MESH_ERROR_BUSY, NULL); > + > + /* Try once more in 1 second */ > + l_timeout_create(1, def_leave, l_dbus_message_ref(msg), NULL); > + return NULL; > + } > > node_remove(node); > > return l_dbus_message_new_method_return(msg); > } > > +static void def_leave(struct l_timeout *timeout, void *user_data) > +{ > + struct l_dbus *dbus = dbus_get_bus(); > + struct l_dbus_message *msg = user_data; > + struct l_dbus_message *reply; > + > + l_timeout_remove(timeout); > + > + reply = leave_call(dbus, msg, (void *) true); Same here. > + l_dbus_send(dbus, reply); > + l_dbus_message_unref(msg); > +} > + > static void create_join_complete_reply_cb(struct l_dbus_message *msg, > void *user_data) > { > -- > 2.25.4 > -- Michał Lowas-Rzechonek Silvair http://silvair.com Jasnogórska 44, 31-358 Krakow, POLAND