mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-19 18:28:25 +00:00
Eliminate redundant UBus notify variable.
There was a `notify` variable to keep track whether a subscriber is observing our UBus object. However, it was not properly cleaned up in `ubus_destroy`, potentially becoming stale over UBus reconnections. The variable was removed and the current state is examined when sending notifications, similarly as is done in other existing OpenWrt code. Signed-off-by: Etan Kissling <etan.kissling@gmail.com>
This commit is contained in:
committed by
Simon Kelley
parent
1bb70e08be
commit
8e9bde57c5
@@ -21,7 +21,6 @@
|
|||||||
#include <libubus.h>
|
#include <libubus.h>
|
||||||
|
|
||||||
static struct blob_buf b;
|
static struct blob_buf b;
|
||||||
static int notify;
|
|
||||||
static int error_logged = 0;
|
static int error_logged = 0;
|
||||||
|
|
||||||
static int ubus_handle_metrics(struct ubus_context *ctx, struct ubus_object *obj,
|
static int ubus_handle_metrics(struct ubus_context *ctx, struct ubus_object *obj,
|
||||||
@@ -78,7 +77,6 @@ static void ubus_subscribe_cb(struct ubus_context *ctx, struct ubus_object *obj)
|
|||||||
(void)ctx;
|
(void)ctx;
|
||||||
|
|
||||||
my_syslog(LOG_DEBUG, _("UBus subscription callback: %s subscriber(s)"), obj->has_subscribers ? "1" : "0");
|
my_syslog(LOG_DEBUG, _("UBus subscription callback: %s subscriber(s)"), obj->has_subscribers ? "1" : "0");
|
||||||
notify = obj->has_subscribers;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ubus_destroy(struct ubus_context *ubus)
|
static void ubus_destroy(struct ubus_context *ubus)
|
||||||
@@ -334,7 +332,7 @@ void ubus_event_bcast(const char *type, const char *mac, const char *ip, const c
|
|||||||
{
|
{
|
||||||
struct ubus_context *ubus = (struct ubus_context *)daemon->ubus;
|
struct ubus_context *ubus = (struct ubus_context *)daemon->ubus;
|
||||||
|
|
||||||
if (!ubus || !notify)
|
if (!ubus || !ubus_object.has_subscribers)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CHECK(blob_buf_init(&b, BLOBMSG_TYPE_TABLE));
|
CHECK(blob_buf_init(&b, BLOBMSG_TYPE_TABLE));
|
||||||
@@ -355,7 +353,7 @@ void ubus_event_bcast_connmark_allowlist_refused(u32 mark, const char *name)
|
|||||||
{
|
{
|
||||||
struct ubus_context *ubus = (struct ubus_context *)daemon->ubus;
|
struct ubus_context *ubus = (struct ubus_context *)daemon->ubus;
|
||||||
|
|
||||||
if (!ubus || !notify)
|
if (!ubus || !ubus_object.has_subscribers)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CHECK(blob_buf_init(&b, 0));
|
CHECK(blob_buf_init(&b, 0));
|
||||||
@@ -369,7 +367,7 @@ void ubus_event_bcast_connmark_allowlist_resolved(u32 mark, const char *name, co
|
|||||||
{
|
{
|
||||||
struct ubus_context *ubus = (struct ubus_context *)daemon->ubus;
|
struct ubus_context *ubus = (struct ubus_context *)daemon->ubus;
|
||||||
|
|
||||||
if (!ubus || !notify)
|
if (!ubus || !ubus_object.has_subscribers)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CHECK(blob_buf_init(&b, 0));
|
CHECK(blob_buf_init(&b, 0));
|
||||||
|
|||||||
Reference in New Issue
Block a user