diff options
| author | Jo-Philipp Wich | 2026-03-27 10:29:50 +0000 |
|---|---|---|
| committer | Jo-Philipp Wich | 2026-03-27 10:34:31 +0000 |
| commit | 5b078674a5929a5c90043c66721d45e1d8eae73d (patch) | |
| tree | 46d02efccf6c07dd7fdb1dac20889f8d7cfcd8c2 | |
| parent | a4a5a298588960638a2e1713eb8fb858e1dbedeb (diff) | |
| download | rpcd-master.tar.gz | |
Replace deferred_reply uloop_timeout with timeout reuse in both
rpc_exec_context and rpc_file_exec_context. This eliminates redundant
state tracking (deferred_reply_pending) and function pointers, reducing
struct sizes and code complexity while maintaining deferred reply
behavior through callback switching.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
| -rw-r--r-- | exec.c | 17 | ||||
| -rw-r--r-- | file.c | 19 | ||||
| -rw-r--r-- | include/rpcd/exec.h | 2 |
3 files changed, 8 insertions, 30 deletions
@@ -122,9 +122,6 @@ rpc_exec_reply(struct rpc_exec_context *c, int rv) { uloop_timeout_cancel(&c->timeout); uloop_process_delete(&c->process); - uloop_timeout_cancel(&c->deferred_reply); - - c->deferred_reply_pending = false; if (rv == UBUS_STATUS_OK) { @@ -159,24 +156,20 @@ rpc_exec_reply(struct rpc_exec_context *c, int rv) } static void -rpc_exec_deferred_reply_cb(struct uloop_timeout *t) +rpc_exec_reply_cb(struct uloop_timeout *t) { struct rpc_exec_context *c = - container_of(t, struct rpc_exec_context, deferred_reply); + container_of(t, struct rpc_exec_context, timeout); - c->deferred_reply_pending = false; rpc_exec_reply(c, c->deferred_status); } static void rpc_exec_schedule_reply(struct rpc_exec_context *c, int rv) { - if (c->deferred_reply_pending) - return; - c->deferred_status = rv; - c->deferred_reply_pending = true; - uloop_timeout_set(&c->deferred_reply, 0); + c->timeout.cb = rpc_exec_reply_cb; + uloop_timeout_set(&c->timeout, 0); } static void @@ -373,8 +366,6 @@ rpc_exec(const char **args, rpc_exec_write_cb_t in, c->process.cb = rpc_exec_process_cb; uloop_process_add(&c->process); - c->deferred_reply.cb = rpc_exec_deferred_reply_cb; - c->timeout.cb = rpc_exec_timeout_cb; uloop_timeout_set(&c->timeout, rpc_exec_timeout); @@ -70,10 +70,8 @@ struct rpc_file_exec_context { struct uloop_process process; struct ustream_fd opipe; struct ustream_fd epipe; - struct uloop_timeout deferred_reply; int stat; int deferred_status; - bool deferred_reply_pending; }; @@ -791,9 +789,6 @@ rpc_file_exec_reply(struct rpc_file_exec_context *c, int rv) { uloop_timeout_cancel(&c->timeout); uloop_process_delete(&c->process); - uloop_timeout_cancel(&c->deferred_reply); - - c->deferred_reply_pending = false; if (rv == UBUS_STATUS_OK) { @@ -820,24 +815,20 @@ rpc_file_exec_reply(struct rpc_file_exec_context *c, int rv) } static void -rpc_file_exec_deferred_reply_cb(struct uloop_timeout *t) +rpc_file_exec_reply_cb(struct uloop_timeout *t) { struct rpc_file_exec_context *c = - container_of(t, struct rpc_file_exec_context, deferred_reply); + container_of(t, struct rpc_file_exec_context, timeout); - c->deferred_reply_pending = false; rpc_file_exec_reply(c, c->deferred_status); } static void rpc_file_exec_schedule_reply(struct rpc_file_exec_context *c, int rv) { - if (c->deferred_reply_pending) - return; - c->deferred_status = rv; - c->deferred_reply_pending = true; - uloop_timeout_set(&c->deferred_reply, 0); + c->timeout.cb = rpc_file_exec_reply_cb; + uloop_timeout_set(&c->timeout, 0); } static void @@ -1061,8 +1052,6 @@ rpc_file_exec_run(const char *cmd, const struct blob_attr *sid, c->process.cb = rpc_file_exec_process_cb; uloop_process_add(&c->process); - c->deferred_reply.cb = rpc_file_exec_deferred_reply_cb; - c->timeout.cb = rpc_file_exec_timeout_cb; uloop_timeout_set(&c->timeout, *ops->exec_timeout); diff --git a/include/rpcd/exec.h b/include/rpcd/exec.h index 6c28864..900d6c1 100644 --- a/include/rpcd/exec.h +++ b/include/rpcd/exec.h @@ -61,7 +61,6 @@ struct rpc_exec_context { struct ubus_request_data request; struct uloop_timeout timeout; struct uloop_process process; - struct uloop_timeout deferred_reply; struct ustream_fd ipipe; struct ustream_fd opipe; struct ustream_fd epipe; @@ -71,7 +70,6 @@ struct rpc_exec_context { char *err; int stat; int deferred_status; - bool deferred_reply_pending; void *priv; bool blob_array; void *blob_cookie; |