#include "afs_completion.h"
struct exec_task {
- struct task task;
+ struct task *task;
struct btr_node *btrn;
char *result_buf;
size_t result_size;
static void exec_pre_select(struct sched *s, struct task *t)
{
- struct exec_task *et = container_of(t, struct exec_task, task);
+ struct exec_task *et = task_context(t);
int ret = btr_node_status(et->btrn, 0, BTR_NT_LEAF);
if (ret != 0)
static int exec_post_select(__a_unused struct sched *s, struct task *t)
{
- struct exec_task *et = container_of(t, struct exec_task, task);
+ struct exec_task *et = task_context(t);
struct btr_node *btrn = et->btrn;
char *buf;
size_t sz;
int ret;
struct sched command_sched = {.default_timeout = {.tv_sec = 1}};
struct exec_task exec_task = {
- .task = {
- .pre_select = exec_pre_select,
- .post_select = exec_post_select,
- .status = "client exec task",
- },
.result_buf = para_strdup(""),
.result_size = 1,
};
goto out;
exec_task.btrn = btr_new_node(&(struct btr_node_description)
EMBRACE(.name = "exec_collect"));
- register_task(&command_sched, &exec_task.task);
+ exec_task.task = task_register(&(struct task_info) {
+ .name = "client exec",
+ .pre_select = exec_pre_select,
+ .post_select = exec_post_select,
+ .context = &exec_task,
+ }, &command_sched);
ret = client_connect(ct, &command_sched, NULL, exec_task.btrn);
if (ret < 0)
goto out;
schedule(&command_sched);
+ sched_shutdown(&command_sched);
*result = exec_task.result_buf;
btr_remove_node(&exec_task.btrn);
ret = 1;