Commit b6f6426b authored by Pavel Emelyanov's avatar Pavel Emelyanov

lib: Tossing bits around

This is to prepare a send-and-recv routine that works on existing socket.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent d30521a3
...@@ -318,17 +318,9 @@ static int criu_connect(void) ...@@ -318,17 +318,9 @@ static int criu_connect(void)
return fd; return fd;
} }
static int send_req_and_recv_resp(CriuReq *req, CriuResp **resp) static int send_req_and_recv_resp_sk(int fd, CriuReq *req, CriuResp **resp)
{ {
int fd; int ret = 0;
int ret = 0;
fd = criu_connect();
if (fd < 0) {
perror("Can't connect to criu");
ret = ECONNREFUSED;
goto exit;
}
if (send_req(fd, req) < 0) { if (send_req(fd, req) < 0) {
ret = ECOMM; ret = ECOMM;
...@@ -353,10 +345,24 @@ static int send_req_and_recv_resp(CriuReq *req, CriuResp **resp) ...@@ -353,10 +345,24 @@ static int send_req_and_recv_resp(CriuReq *req, CriuResp **resp)
} }
exit: exit:
if (fd >= 0) return -ret;
}
static int send_req_and_recv_resp(CriuReq *req, CriuResp **resp)
{
int fd;
int ret = 0;
fd = criu_connect();
if (fd < 0) {
perror("Can't connect to criu");
ret = ECONNREFUSED;
} else {
ret = send_req_and_recv_resp_sk(fd, req, resp);
close(fd); close(fd);
}
return -ret; return ret;
} }
int criu_check(void) int criu_check(void)
......
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