Commit 66170c6b authored by Pavel Emelyanov's avatar Pavel Emelyanov

service: Allow to server more requests after page-server start

The problem with several requests is that criu leaks resources after
doing dump/restore. It's OK since process exits anyway, but for
multy requests per connection it's better to audit this thing.

For now -- allow to do requests after the page-server-start one only.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent eed38acc
......@@ -528,16 +528,41 @@ out:
return send_criu_msg(sk, &resp);
}
static int chk_keepopen_req(CriuReq *msg)
{
if (!msg->keep_open)
return 0;
/*
* Service may (well, it will) leave some
* resources leaked after processing e.g.
* dump or restore requests. Before we audit
* the code for this, let's first enable
* mreq RPCs for those requests we know do
* good work
*/
if (msg->type == CRIU_REQ_TYPE__PAGE_SERVER)
/* This just fork()-s so no leaks */
return 0;
return -1;
}
int cr_service_work(int sk)
{
int ret = -1;
CriuReq *msg = 0;
more:
if (recv_criu_msg(sk, &msg) == -1) {
pr_perror("Can't recv request");
goto err;
}
if (chk_keepopen_req(msg))
goto err;
switch (msg->type) {
case CRIU_REQ_TYPE__DUMP:
ret = dump_using_req(sk, msg->opts);
......@@ -559,6 +584,13 @@ int cr_service_work(int sk)
send_criu_err(sk, "Invalid req");
break;
}
if (!ret && msg->keep_open) {
criu_req__free_unpacked(msg, NULL);
ret = -1;
goto more;
}
err:
return ret;
}
......
......@@ -89,6 +89,13 @@ message criu_req {
optional criu_opts opts = 2;
optional bool notify_success = 3;
/*
* When set service won't close the connection but
* will wait for more req-s to appear. Works not
* for all request types.
*/
optional bool keep_open = 4;
}
/*
......
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