mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 14:25:49 +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:
32
lib/criu.c
32
lib/criu.c
@@ -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;
|
||||
|
Reference in New Issue
Block a user