mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2025-12-09 23:34:38 +01:00
bbfdmd: make ubus timeout configurable for every service using JSON register service
This commit is contained in:
parent
22cc348d27
commit
ae1c44524d
4 changed files with 12 additions and 4 deletions
|
|
@ -108,7 +108,7 @@ static void verify_service(struct ubus_context *ubus_ctx, service_entry_t *servi
|
|||
tracker->service = service;
|
||||
|
||||
tracker->timeout.cb = service_request_timeout;
|
||||
uloop_timeout_set(&tracker->timeout, SERVICE_CALL_TIMEOUT);
|
||||
uloop_timeout_set(&tracker->timeout, service->timeout);
|
||||
|
||||
memset(&req_buf, 0, sizeof(struct blob_buf));
|
||||
blob_buf_init(&req_buf, 0);
|
||||
|
|
|
|||
|
|
@ -404,7 +404,7 @@ void run_async_call(struct async_request_context *ctx, service_entry_t *service,
|
|||
snprintf(tracker->request_name, sizeof(tracker->request_name), "%s->%s", service->name, ctx->ubus_method);
|
||||
|
||||
tracker->timeout.cb = handle_request_timeout;
|
||||
uloop_timeout_set(&tracker->timeout, !strcmp(ctx->ubus_method, "operate") ? SERVICE_CALL_OPERATE_TIMEOUT : SERVICE_CALL_TIMEOUT);
|
||||
uloop_timeout_set(&tracker->timeout, !strcmp(ctx->ubus_method, "operate") ? SERVICE_CALL_OPERATE_TIMEOUT : service->timeout);
|
||||
|
||||
if (g_log_level == LOG_DEBUG) {
|
||||
char *json_str = blobmsg_format_json_indent(req_buf.head, true, -1);
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@
|
|||
|
||||
LIST_HEAD(registered_services);
|
||||
|
||||
static void add_service_to_list(const char *name, struct blob_buf *dm_schema, int service_proto, service_object_t *objects, size_t count, bool is_unified)
|
||||
static void add_service_to_list(const char *name, struct blob_buf *dm_schema, int service_proto, int service_timeout,
|
||||
service_object_t *objects, size_t count, bool is_unified)
|
||||
{
|
||||
service_entry_t *service = NULL;
|
||||
|
||||
|
|
@ -42,6 +43,7 @@ static void add_service_to_list(const char *name, struct blob_buf *dm_schema, in
|
|||
service->name = strdup(name);
|
||||
service->dm_schema = dm_schema;
|
||||
service->protocol = service_proto;
|
||||
service->timeout = service_timeout;
|
||||
service->objects = objects;
|
||||
service->object_count = count;
|
||||
service->is_unified = is_unified;
|
||||
|
|
@ -158,6 +160,10 @@ static int load_service_from_file(struct ubus_context *ubus_ctx, const char *fil
|
|||
json_object_object_get_ex(daemon_config, "proto", &proto_jobj);
|
||||
int service_proto = get_proto_type(proto_jobj ? json_object_get_string(proto_jobj) : "");
|
||||
|
||||
json_object *timeout_jobj = NULL;
|
||||
json_object_object_get_ex(daemon_config, "timeout", &timeout_jobj);
|
||||
int service_timeout = timeout_jobj ? json_object_get_int(timeout_jobj) : SERVICE_CALL_TIMEOUT;
|
||||
|
||||
json_object *services_array = NULL;
|
||||
if (!json_object_object_get_ex(daemon_config, "services", &services_array) || json_object_get_type(services_array) != json_type_array) {
|
||||
json_object_put(json_root);
|
||||
|
|
@ -199,7 +205,7 @@ static int load_service_from_file(struct ubus_context *ubus_ctx, const char *fil
|
|||
}
|
||||
|
||||
BBFDM_INFO("Registering [%s :: %lu :: %d]", service_name, num_objs, is_unified);
|
||||
add_service_to_list(service_name, service_schema, service_proto, objects, num_objs, is_unified);
|
||||
add_service_to_list(service_name, service_schema, service_proto, service_timeout, objects, num_objs, is_unified);
|
||||
json_object_put(json_root);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -287,6 +293,7 @@ void list_registered_services(struct blob_buf *bb)
|
|||
|
||||
blobmsg_add_u8(bb, "unified_daemon", service->is_unified);
|
||||
blobmsg_add_u8(bb, "blacklisted", service->is_blacklisted);
|
||||
blobmsg_add_u32(bb, "timeout", service->timeout);
|
||||
|
||||
void *objects_array = blobmsg_open_array(bb, "objects");
|
||||
for (size_t i = 0; i < service->object_count; i++) {
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ typedef struct service_entry {
|
|||
bool is_unified;
|
||||
size_t object_count;
|
||||
service_object_t *objects;
|
||||
int timeout; // Ubus timeout used to get data from lower layer
|
||||
int consecutive_timeouts; // Tracks successive timeouts
|
||||
bool is_blacklisted; // Marks if the service is blacklisted
|
||||
} service_entry_t;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue