mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2026-01-27 17:37:17 +01:00
Fix Add/Del events in operate commands
This commit is contained in:
parent
c252002089
commit
56312c7b03
3 changed files with 10 additions and 6 deletions
|
|
@ -167,6 +167,9 @@ static void async_complete_cb(struct uloop_process *p, __attribute__((unused)) i
|
|||
ubus_send_reply(r->ctx, &r->req, bb->head);
|
||||
INFO("pid(%d) blob data sent raw(%d)", r->process.pid, blob_raw_len(bb->head));
|
||||
ubus_complete_deferred_request(r->ctx, &r->req, 0);
|
||||
if (r->is_operate) {
|
||||
register_instance_refresh_timer(r->ctx, 0);
|
||||
}
|
||||
munmap(r->result, DEF_IPC_DATA_LEN);
|
||||
async_req_free(r);
|
||||
}
|
||||
|
|
@ -185,7 +188,7 @@ static struct bbfdm_async_req *async_req_new(void)
|
|||
return r;
|
||||
}
|
||||
|
||||
static int bbfdm_start_deferred(bbfdm_data_t *data, void (*EXEC_CB)(bbfdm_data_t *data, void *d))
|
||||
static int bbfdm_start_deferred(bbfdm_data_t *data, void (*EXEC_CB)(bbfdm_data_t *data, void *d), bool is_operate)
|
||||
{
|
||||
struct bbfdm_async_req *r = NULL;
|
||||
pid_t child;
|
||||
|
|
@ -240,6 +243,7 @@ static int bbfdm_start_deferred(bbfdm_data_t *data, void (*EXEC_CB)(bbfdm_data_t
|
|||
r->ctx = data->ctx;
|
||||
r->process.pid = child;
|
||||
r->process.cb = async_complete_cb;
|
||||
r->is_operate = is_operate;
|
||||
uloop_process_add(&r->process);
|
||||
ubus_defer_request(data->ctx, data->req, &r->req);
|
||||
return 0;
|
||||
|
|
@ -364,7 +368,7 @@ static int bbfdm_get_handler(struct ubus_context *ctx, struct ubus_object *obj _
|
|||
|
||||
if (is_subprocess_needed) {
|
||||
INFO("Creating subprocess for get method");
|
||||
bbfdm_start_deferred(&data, bbfdm_get_value);
|
||||
bbfdm_start_deferred(&data, bbfdm_get_value, false);
|
||||
} else {
|
||||
bbfdm_get_value(&data, NULL);
|
||||
}
|
||||
|
|
@ -648,8 +652,7 @@ static int bbfdm_operate_handler(struct ubus_context *ctx, struct ubus_object *o
|
|||
bbfdm_operate_cmd_sync(&data);
|
||||
} else {
|
||||
cancel_instance_refresh_timer(ctx);
|
||||
bbfdm_start_deferred(&data, bbfdm_operate_cmd_async);
|
||||
register_instance_refresh_timer(ctx, 0);
|
||||
bbfdm_start_deferred(&data, bbfdm_operate_cmd_async, true);
|
||||
}
|
||||
|
||||
FREE(str);
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ struct bbfdm_async_req {
|
|||
struct ubus_context *ctx;
|
||||
struct ubus_request_data req;
|
||||
struct uloop_process process;
|
||||
bool is_operate;
|
||||
void *result;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ static void bbfdm_event_handler(struct ubus_context *ctx, struct ubus_event_hand
|
|||
blobmsg_add_string(&b, "name", param->data);
|
||||
strncpyt(dm_path, param->data, sizeof(dm_path));
|
||||
} else {
|
||||
blobmsg_add_string(&bb, param->name, param->data);
|
||||
blobmsg_add_string(&b, param->name, param->data);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -100,7 +100,7 @@ static void bbfdm_event_handler(struct ubus_context *ctx, struct ubus_event_hand
|
|||
blobmsg_add_field(&b, BLOBMSG_TYPE_TABLE, "input", blob_data(bb.head), blob_len(bb.head));
|
||||
|
||||
ubus_send_event(ctx, method_name, b.head);
|
||||
DEBUG("Event[%s], for [%s] sent", method_name, dm_path);
|
||||
INFO("Event[%s], for [%s] sent", method_name, dm_path);
|
||||
|
||||
blob_buf_free(&bb);
|
||||
blob_buf_free(&b);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue