[CRIU] [PATCH v5 19/33] inet: Link sockets in port_type list
Kirill Tkhai
ktkhai at virtuozzo.com
Mon Dec 26 06:27:45 PST 2016
This is need for waiting, while port has users, using task_st futex.
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
criu/include/sk-inet.h | 1 +
criu/sk-inet.c | 11 ++++++++---
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/criu/include/sk-inet.h b/criu/include/sk-inet.h
index db3317f7d..7b6e581e1 100644
--- a/criu/include/sk-inet.h
+++ b/criu/include/sk-inet.h
@@ -41,6 +41,7 @@ struct inet_sk_info {
InetSkEntry *ie;
struct file_desc d;
struct inet_port *port;
+ struct list_head port_list;
/*
* This is an fd by which the socket is opened.
* It will be carried down to restorer code to
diff --git a/criu/sk-inet.c b/criu/sk-inet.c
index 0a6487aea..ed4e77630 100644
--- a/criu/sk-inet.c
+++ b/criu/sk-inet.c
@@ -34,19 +34,21 @@ static LIST_HEAD(inet_ports);
struct inet_port {
int port;
int type;
+ struct list_head type_list;
futex_t users;
mutex_t reuseaddr_lock;
struct list_head list;
};
-static struct inet_port *port_add(int type, int port)
+static struct inet_port *port_add(struct inet_sk_info *ii, int port)
{
+ int type = ii->ie->type;
struct inet_port *e;
list_for_each_entry(e, &inet_ports, list)
if (e->type == type && e->port == port) {
futex_inc(&e->users);
- return e;
+ goto out_link;
}
e = shmalloc(sizeof(*e));
@@ -60,8 +62,11 @@ static struct inet_port *port_add(int type, int port)
futex_init(&e->users);
futex_inc(&e->users);
mutex_init(&e->reuseaddr_lock);
+ INIT_LIST_HEAD(&e->type_list);
list_add(&e->list, &inet_ports);
+out_link:
+ list_add(&ii->port_list, &e->type_list);
return e;
}
@@ -507,7 +512,7 @@ static int collect_one_inetsk(void *o, ProtobufCMessage *base, struct cr_img *i)
* so a value of SO_REUSEADDR can be restored after restoring all
* sockets.
*/
- ii->port = port_add(ii->ie->type, ii->ie->src_port);
+ ii->port = port_add(ii, ii->ie->src_port);
if (ii->port == NULL)
return -1;
More information about the CRIU
mailing list