mirror of
https://github.com/checkpoint-restore/criu
synced 2025-09-03 15:55:53 +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:
30
lib/criu.c
30
lib/criu.c
@@ -318,18 +318,10 @@ 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;
|
||||||
goto exit;
|
goto exit;
|
||||||
@@ -353,12 +345,26 @@ static int send_req_and_recv_resp(CriuReq *req, CriuResp **resp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
if (fd >= 0)
|
|
||||||
close(fd);
|
|
||||||
|
|
||||||
return -ret;
|
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 criu_check(void)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
Reference in New Issue
Block a user