From d04b837e6b24d0fdbe5803a98c9c7f099748bfee Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sun, 26 Feb 2012 12:53:43 +0100 Subject: [PATCH] client: Improve error diagnostics. If an error occurs in the post_select() method of the client task, the scheduler removes this task from the task list and then returns zero to indicate that the task list has become empty. Currently, client.c looks only at the return value of schedule() and therefore returns success in this case. This patch makes client.c additionally check the task error state of the client task and prints an error message if it was negative and different from an EOF condition. --- client.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/client.c b/client.c index 5f511708..4998222e 100644 --- a/client.c +++ b/client.c @@ -603,14 +603,22 @@ int main(int argc, char *argv[]) EMBRACE(.name = "stdout", .parent = ct->btrn)); register_task(&sched, &svt); ret = schedule(&sched); + if (ret >= 0 && ct->task.error < 0) { + switch(ct->task.error) { + /* these are not errors */ + case -E_EOF: + case -E_SERVER_EOF: + case -E_BTR_EOF: + ret = 0; + break; + default: ret = ct->task.error; + } + } out: + if (ret < 0) + PARA_ERROR_LOG("%s\n", para_strerror(-ret)); client_close(ct); btr_free_node(sit.btrn); btr_free_node(sot.btrn); - if (ret < 0) { - /* can not use PARA_LOG here because ct is NULL */ - fprintf(stderr, "%s\n", para_strerror(-ret)); - return EXIT_FAILURE; - } - return EXIT_SUCCESS; + return ret < 0? EXIT_FAILURE : EXIT_SUCCESS; } -- 2.39.5