Commit 0a4b2103 authored by Pavel Emelyanov's avatar Pavel Emelyanov

service: Factor out err setting

Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
Acked-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 06e25b18
...@@ -110,6 +110,12 @@ err: ...@@ -110,6 +110,12 @@ err:
return -1; return -1;
} }
static void set_resp_err(CriuResp *resp)
{
resp->cr_errno = get_cr_errno();
resp->has_cr_errno = resp->cr_errno ? true : false;
}
static void send_criu_err(int sk, char *msg) static void send_criu_err(int sk, char *msg)
{ {
CriuResp resp = CRIU_RESP__INIT; CriuResp resp = CRIU_RESP__INIT;
...@@ -118,10 +124,7 @@ static void send_criu_err(int sk, char *msg) ...@@ -118,10 +124,7 @@ static void send_criu_err(int sk, char *msg)
resp.type = CRIU_REQ_TYPE__EMPTY; resp.type = CRIU_REQ_TYPE__EMPTY;
resp.success = false; resp.success = false;
if (get_cr_errno()) { set_resp_err(&resp);
resp.has_cr_errno = true;
resp.cr_errno = get_cr_errno();
}
send_criu_msg(sk, &resp); send_criu_msg(sk, &resp);
} }
...@@ -133,10 +136,7 @@ int send_criu_dump_resp(int socket_fd, bool success, bool restored) ...@@ -133,10 +136,7 @@ int send_criu_dump_resp(int socket_fd, bool success, bool restored)
msg.type = CRIU_REQ_TYPE__DUMP; msg.type = CRIU_REQ_TYPE__DUMP;
msg.success = success; msg.success = success;
if (get_cr_errno()) { set_resp_err(&msg);
msg.has_cr_errno = true;
msg.cr_errno = get_cr_errno();
}
msg.dump = &resp; msg.dump = &resp;
resp.has_restored = true; resp.has_restored = true;
...@@ -151,10 +151,7 @@ static int send_criu_pre_dump_resp(int socket_fd, bool success) ...@@ -151,10 +151,7 @@ static int send_criu_pre_dump_resp(int socket_fd, bool success)
msg.type = CRIU_REQ_TYPE__PRE_DUMP; msg.type = CRIU_REQ_TYPE__PRE_DUMP;
msg.success = success; msg.success = success;
if (get_cr_errno()) { set_resp_err(&msg);
msg.has_cr_errno = true;
msg.cr_errno = get_cr_errno();
}
return send_criu_msg(socket_fd, &msg); return send_criu_msg(socket_fd, &msg);
} }
...@@ -166,10 +163,7 @@ int send_criu_restore_resp(int socket_fd, bool success, int pid) ...@@ -166,10 +163,7 @@ int send_criu_restore_resp(int socket_fd, bool success, int pid)
msg.type = CRIU_REQ_TYPE__RESTORE; msg.type = CRIU_REQ_TYPE__RESTORE;
msg.success = success; msg.success = success;
if (get_cr_errno()) { set_resp_err(&msg);
msg.has_cr_errno = true;
msg.cr_errno = get_cr_errno();
}
msg.restore = &resp; msg.restore = &resp;
resp.pid = pid; resp.pid = pid;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment