From patchwork Tue Jan 16 17:13:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dirk Feytons X-Patchwork-Id: 861778 X-Patchwork-Delegate: blogic@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ICClfUu4"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="KXb3TK9Q"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zLcJk27b8z9t2c for ; Wed, 17 Jan 2018 04:14:14 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Subject:Message-Id: Date:To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=VBJQzwkjDCzBfhjDWGcHh5RCz4NwEyx4FndBplk6K0g=; b=ICClfUu4GT98EC 1AcbD/D/ONlbIFfj714YDz4PEkC4toCgu0Dz5qlBCfIa+H+4r6nBDy8euz7izTsOHlzbRoNw+GP/4 GllaRlGMU8M4U5yZA3BjRH/Hj+R0BRHZnd8JMKOhrmCs8G5MHdPAjLfk57CdaX4zDXAVe+3Hj+mSq np9pMCzfUWKJs/P9/oPlNv51T6d9mewi2ssB0TyROPSlMGh1aIpUeBf8jZxJownqWImHKPocxa7oj Jd+lKa5T9FoYVybjeRPY2KXisw4UhTjGPvmBtFI+IrK8gKbl7+ICGGS5Lz8tTBsR8KS9hH3erbHFr XslCHz+zUy/7mIFlUuIA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1ebUoN-0006C5-83; Tue, 16 Jan 2018 17:14:11 +0000 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ebUoE-0005sw-65 for lede-dev@lists.infradead.org; Tue, 16 Jan 2018 17:14:06 +0000 Received: by mail-wr0-x242.google.com with SMTP id e41so15661301wre.9 for ; Tue, 16 Jan 2018 09:13:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=PbsOfe5Ue9nhJ92Tdt5/i0dWQiip2KqQh61+gO4L+oQ=; b=KXb3TK9QokKxHX3s8n/oEwGZeONDxjE5gnbfHQkuvZysD46FQjQpG6DyvHFeCLkZ7L H0JQkTGXbgfxoivoZCSUtVJ356I3CBKBNEKZBge2/mscyh8U//UouxNJE2Q415yz79Hk eEzZtNXEEZ7JV7nrU0of2O+NiQtRZHthoju1C6qr5twWnLszc1xBZ9ASs9n8wtsnQ2tx HWHy4poLrWE5zp31Ulqg0VO4EiSuW7rn3PKbmli3ODf4LIBqEY4siZDWeR4pbv34aEuz 02mCJOJ4v2Ewom+/CGpin525llGLfLegl44vF0Z6dxlVHk97/GEUNh6PWJ4VjHjNNwaE rQLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=PbsOfe5Ue9nhJ92Tdt5/i0dWQiip2KqQh61+gO4L+oQ=; b=oqliH1p5jDiuXXPxsPuVMxHUyX6upJI6jd7NW42gMJdP9BIMhqAkTOh++oqqDOdEPm EyMw4d3vx0qiOAsY7JFv2wIqqc15lP6YA0OTUrzji3Ws9c5YGPS3kGCJzAlNHblhYsjQ yuG1yE8C38TWjsRis9LPDDdOEtbKrxbZ06oWs11F1TnBCBGbfKhCtRZv8g7091C2woSC Q3Iz8ETCu5rxJj4IZ645ResStvuS9WOlbaIIoK8J2gcUEHLcfvphndcdKv4mvqk2mqTx XIVREeIQQyqNUdHBe+C1hrQG/+wnICzwSHY6eUxdMDNJWY18pOSMM7Nj1ntwuQ1ON9fY /kHw== X-Gm-Message-State: AKwxyteU94NaeTWsGGiKATs8ygY00bupSk1a18BIJPiTQ0uY26HhKnnk GvpFMm/037LY/hKrxmVT3p0UE0OG+mE= X-Google-Smtp-Source: ACJfBotl460YBFSHdbcGX+VAxfZIl+3yLt8SNwc6r3E8dn25xNzIn0QgGDdiB9XwhtnZzCgzFG6mvg== X-Received: by 10.223.139.11 with SMTP id n11mr14763461wra.102.1516122829396; Tue, 16 Jan 2018 09:13:49 -0800 (PST) Received: from cplx1020.edegem.eu.thmulti.com ([141.11.62.7]) by smtp.gmail.com with ESMTPSA id 127sm4227408wmk.14.2018.01.16.09.13.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Jan 2018 09:13:48 -0800 (PST) From: Dirk Feytons To: lede-dev@lists.infradead.org, nbd@nbd.name Date: Tue, 16 Jan 2018 18:13:39 +0100 Message-Id: <1516122819-23250-1-git-send-email-dirk.feytons@gmail.com> X-Mailer: git-send-email 1.7.9.5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180116_091402_592623_1A79DE87 X-CRM114-Status: UNSURE ( 8.57 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:400c:c0c:0:0:0:242 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (dirk.feytons[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Subject: [LEDE-DEV] [PATCH] ubus/lua: pass notification name to callback X-BeenThere: lede-dev@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dirk Feytons MIME-Version: 1.0 Sender: "Lede-dev" Errors-To: lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The callback function registered to be invoked when subscribing to a notification was only passed the notification data (if any) but not the name of the notification. This name is now passed as second argument to remain backwards compatible. The example subscriber.lua has also be updated. Signed-off-by: Dirk Feytons --- lua/subscriber.lua | 5 +++-- lua/ubus.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lua/subscriber.lua b/lua/subscriber.lua index e1d3a9f..f59448d 100755 --- a/lua/subscriber.lua +++ b/lua/subscriber.lua @@ -15,8 +15,9 @@ if not conn then end local sub = { - notify = function( msg ) - print("Count: ", msg["count"]) + notify = function( msg, name ) + print("name:", name) + print(" count:", msg["count"]) end, } diff --git a/lua/ubus.c b/lua/ubus.c index cfe9c9b..00d9e00 100644 --- a/lua/ubus.c +++ b/lua/ubus.c @@ -787,10 +787,11 @@ ubus_sub_notify_handler(struct ubus_context *ctx, struct ubus_object *obj, if (lua_isfunction(state, -1)) { if( msg ){ ubus_lua_parse_blob_array(state, blob_data(msg), blob_len(msg), true); - lua_call(state, 1, 0); } else { - lua_call(state, 0, 0); + lua_pushnil(state); } + lua_pushstring(state, method); + lua_call(state, 2, 0); } else { lua_pop(state, 1); }