Commit 61490ba9 authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

files: add one more operation post_create

It will be used for restoring inet sockets. An inet socket is created with
the option REUSEADDR, because the restore logic requires this.
The origin value can be restored only when all sockets were restored.
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent b719b93d
......@@ -319,6 +319,19 @@ int send_fd_to_peer(int fd, struct fdinfo_list_entry *fle, int sock)
return send_fd(sock, &saddr, len, fd);
}
static int post_open_fd(int pid, FdinfoEntry *fe, struct file_desc *d)
{
struct fdinfo_list_entry *fle;
fle = file_master(d);
if ((fle->pid != pid) || (fe->fd != fle->fe->fd))
return 0;
if (d->ops->post_open && d->ops->post_open(d, fle->fe->fd))
return -1;
return 0;
}
static int open_fd(int pid, FdinfoEntry *fe, struct file_desc *d)
{
int tmp;
......@@ -405,6 +418,7 @@ static int receive_fd(int pid, FdinfoEntry *fe, struct file_desc *d)
static char *fdinfo_states[FD_STATE_MAX] = {
[FD_STATE_PREP] = "prepare",
[FD_STATE_CREATE] = "create",
[FD_STATE_POST_CREATE] = "post_create",
[FD_STATE_RECV] = "receive",
};
......@@ -423,6 +437,9 @@ static int open_fdinfo(int pid, struct fdinfo_list_entry *fle, int state)
case FD_STATE_CREATE:
ret = open_fd(pid, fle->fe, fle->desc);
break;
case FD_STATE_POST_CREATE:
ret = post_open_fd(pid, fle->fe, fle->desc);
break;
case FD_STATE_RECV:
ret = receive_fd(pid, fle->fe, fle->desc);
break;
......
......@@ -35,6 +35,7 @@ struct fd_parms {
enum fdinfo_states {
FD_STATE_PREP, /* Create unix sockets */
FD_STATE_CREATE, /* Create and send fd */
FD_STATE_POST_CREATE, /* Execute actions, when everyone was created */
FD_STATE_RECV, /* Receive fd */
FD_STATE_MAX
......@@ -54,6 +55,7 @@ struct fdinfo_list_entry {
struct file_desc_ops {
unsigned int type;
int (*open)(struct file_desc *d);
int (*post_open)(struct file_desc *d, int fd);
int (*want_transport)(FdinfoEntry *fe, struct file_desc *d);
};
......
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