X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=client.c;h=873edc163b3e5f5164307d647724cf6655ec0d5f;hp=89171a23b7f0b22b1940e3e54e74d000d36f7245;hb=b3644a3f5de245609dc608a947ed71e2f75b2fd5;hpb=38aeac398e716ff7ae6919acbdf498ed09ab0bc1 diff --git a/client.c b/client.c index 89171a23..873edc16 100644 --- a/client.c +++ b/client.c @@ -95,8 +95,7 @@ static int execute_client_command(const char *cmd, char **result) struct exec_task exec_task = { .task = { .pre_select = exec_pre_select, - .new_post_select = exec_post_select, - .post_select = NULL, + .post_select = exec_post_select, .status = "client exec task", }, .result_buf = para_strdup(""), @@ -446,16 +445,14 @@ static int client_i9e_line_handler(char *line) int ret; client_disconnect(ct); - if (!line || !*line) - return 0; - PARA_DEBUG_LOG("line handler: %s\n", line); + PARA_DEBUG_LOG("line: %s\n", line); ret = make_client_argv(line); - if (ret < 0) + if (ret <= 0) return ret; ret = client_connect(ct, &sched, NULL, NULL); if (ret < 0) return ret; - i9e_attach_to_stdout(ct->btrn); + i9e_attach_to_stdout(ct->btrn[0]); return 1; } @@ -478,7 +475,7 @@ __noreturn static void interactive_session(void) .completers = completers, }; - PARA_NOTICE_LOG("\n%s\n", VERSION_TEXT("client")); + PARA_NOTICE_LOG("\n%s\n", version_text("client")); if (ct->conf.history_file_given) history_file = para_strdup(ct->conf.history_file_arg); else { @@ -531,27 +528,37 @@ __noreturn static void print_completions(void) #endif /* HAVE_READLINE */ -static int supervisor_post_select(struct sched *s, __a_unused struct task *t) +struct supervisor_task { + bool stdout_task_started; + struct task task; +}; + +static int supervisor_post_select(struct sched *s, struct task *t) { + struct supervisor_task *svt = container_of(t, struct supervisor_task, + task); + if (ct->task.error < 0) return ct->task.error; + if (!svt->stdout_task_started && ct->status == CL_EXECUTING) { + stdout_set_defaults(&sot); + register_task(s, &sot.task); + svt->stdout_task_started = true; + return 1; + } if (ct->status == CL_SENDING) { stdin_set_defaults(&sit); register_task(s, &sit.task); return -E_TASK_STARTED; } - if (ct->status == CL_RECEIVING) { - stdout_set_defaults(&sot); - register_task(s, &sot.task); - return -E_TASK_STARTED; - } return 0; } -static struct task svt = { - .new_post_select = supervisor_post_select, - .post_select = NULL, - .status = "supervisor task" +static struct supervisor_task supervisor_task = { + .task = { + .post_select = supervisor_post_select, + .status = "supervisor task" + } }; /** @@ -599,8 +606,8 @@ int main(int argc, char *argv[]) if (ret < 0) goto out; sot.btrn = btr_new_node(&(struct btr_node_description) - EMBRACE(.name = "stdout", .parent = ct->btrn)); - register_task(&sched, &svt); + EMBRACE(.name = "stdout", .parent = ct->btrn[0])); + register_task(&sched, &supervisor_task.task); ret = schedule(&sched); if (ret >= 0 && ct->task.error < 0) { switch(ct->task.error) {