[CRIU] [PATCH 1/5] service: move worker's code in a separate function (v2)
Andrey Vagin
avagin at openvz.org
Thu Sep 19 06:57:04 EDT 2013
I think it's more readable
v2: rebase on the current upstream git
Cc: Ruslan Kuprieiev <kupruser at gmail.com>
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
cr-service.c | 51 ++++++++++++++++++++++++++++-----------------------
1 file changed, 28 insertions(+), 23 deletions(-)
diff --git a/cr-service.c b/cr-service.c
index 99b3cfd..059aee4 100644
--- a/cr-service.c
+++ b/cr-service.c
@@ -176,6 +176,33 @@ exit:
return success ? 0 : 1;
}
+static int cr_service_work(CriuReq *msg)
+{
+ if (recv_criu_msg(cr_service_client->sk_fd,
+ &msg) == -1) {
+ pr_perror("Can't recv request");
+ goto err;
+ }
+
+ switch (msg->type) {
+ case CRIU_REQ_TYPE__DUMP:
+ return dump_using_req(msg->dump);
+
+ default:
+ pr_perror("Invalid request");
+ goto err;
+ }
+
+err:
+ /*
+ * FIXME -- add generic error report
+ */
+
+ close(cr_service_client->sk_fd);
+
+ return 1;
+}
+
int cr_service(bool daemon_mode)
{
int server_fd;
@@ -267,29 +294,7 @@ int cr_service(bool daemon_mode)
continue;
case 0:
- if (recv_criu_msg(cr_service_client->sk_fd,
- &msg) == -1) {
- pr_perror("Can't recv request");
- goto err;
- }
-
- switch (msg->type) {
- case CRIU_REQ_TYPE__DUMP:
- exit(dump_using_req(msg->dump));
-
- default:
- pr_perror("Invalid request");
- goto err;
- }
-
-err:
- /*
- * FIXME -- add generic error report
- */
-
- close(cr_service_client->sk_fd);
- exit(-1);
-
+ exit(cr_service_work(msg));
default:
close(cr_service_client->sk_fd);
}
--
1.8.3.1
More information about the CRIU
mailing list