2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 22:35:33 +00:00

lib: Tossing bits around

This is to prepare a send-and-recv routine that works on existing socket.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Pavel Emelyanov
2014-06-17 21:09:25 +04:00
parent d30521a3cf
commit b6f6426bef

View File

@@ -318,17 +318,9 @@ static int criu_connect(void)
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;
fd = criu_connect();
if (fd < 0) {
perror("Can't connect to criu");
ret = ECONNREFUSED;
goto exit;
}
int ret = 0;
if (send_req(fd, req) < 0) {
ret = ECOMM;
@@ -353,12 +345,26 @@ static int send_req_and_recv_resp(CriuReq *req, CriuResp **resp)
}
exit:
if (fd >= 0)
close(fd);
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);
}
return ret;
}
int criu_check(void)
{
int ret = -1;