Revert "Feature #15351: Improve instance refresh logic to monitor uci changes by external packages"

This commit is contained in:
Amin Ben Romdhane 2024-10-24 08:58:23 +00:00 committed by IOPSYS Dev
parent a813bf2715
commit b9202e8605
No known key found for this signature in database

View file

@ -28,8 +28,6 @@
uint8_t g_log_level = 1;
void print_log(const char *format, ...);
#define PRINT_ERR(fmt, args...) \
print_err(fmt, ##args)
@ -56,8 +54,6 @@ static struct proto_args supported_protocols[] = {
},
};
static time_t last_config_change_time = 0;
// Structure to represent an instance of a service
struct instance {
char name[NAME_LENGTH];
@ -522,7 +518,10 @@ end:
ubus_send_reply(ctx, req, bb.head);
blob_buf_free(&bb);
// Send 'bbf.config.change' event to run refresh instances
send_bbf_config_change_event();
PRINT_INFO("Commit handler exit");
return 0;
}
@ -569,7 +568,10 @@ end:
ubus_send_reply(ctx, req, bb.head);
blob_buf_free(&bb);
// Send 'bbf.config.change' event to run refresh instances
send_bbf_config_change_event();
PRINT_INFO("revert handler exit");
return 0;
}
@ -633,32 +635,10 @@ static void usage(char *prog)
fprintf(stderr, "\n");
}
static int config_change_receive_request(struct ubus_context *ctx, struct ubus_object *obj,
struct ubus_request_data *req,
const char *method, struct blob_attr *msg)
{
if (strcmp(method, "config.change") != 0)
return -1;
time_t time_now = time(NULL);
if (time_now - last_config_change_time > 2) {
// Send 'bbf.config.change' event to run refresh instances
send_bbf_config_change_event();
}
last_config_change_time = time_now;
return 0;
}
int main(int argc, char **argv)
{
struct ubus_context *uctx = NULL;
struct ubus_subscriber sub = {
.cb = config_change_receive_request
};
int ch, ret = 0;
struct ubus_context *uctx;
int ch;
openlog("bbf.config", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
@ -687,23 +667,6 @@ int main(int argc, char **argv)
if (ubus_add_object(uctx, &bbf_config_object))
goto exit;
ret = ubus_register_subscriber(uctx, &sub);
if (!ret) {
uint32_t id;
ret = ubus_lookup_id(uctx, "service", &id);
if (ret) {
PRINT_ERR("Failed to get service method, exiting");
goto exit;
}
ret = ubus_subscribe(uctx, &sub, id);
if (ret) {
PRINT_ERR("Failed to subscribe to service method, exiting");
goto exit;
}
}
uloop_run();
exit: