[CRIU] [PATCH 01/14] tcp: Make reuse crit section wider
Pavel Emelyanov
xemul at virtuozzo.com
Mon Apr 18 06:02:16 PDT 2016
This lock will have to be moved into the libsocr which is
not nice, so pull this out of the restore_tcp_queues.
And, since we're extending the section anyway, pull it away
from sk-tcp.c at all. Makes the code a little bit cleaner.
Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
criu/include/sk-inet.h | 1 -
criu/sk-inet.c | 11 +++++------
criu/sk-tcp.c | 14 ++++----------
3 files changed, 9 insertions(+), 17 deletions(-)
diff --git a/criu/include/sk-inet.h b/criu/include/sk-inet.h
index ae6082d..fe28376 100644
--- a/criu/include/sk-inet.h
+++ b/criu/include/sk-inet.h
@@ -74,7 +74,6 @@ extern int restore_one_tcp(int sk, struct inet_sk_info *si);
#define SK_EST_PARAM "tcp-established"
extern int check_tcp(void);
-extern mutex_t *inet_get_reuseaddr_lock(struct inet_sk_info *ii);
int rst_tcp_socks_prep(void);
extern unsigned long rst_tcp_socks_cpos;
diff --git a/criu/sk-inet.c b/criu/sk-inet.c
index 460e237..aeb948d 100644
--- a/criu/sk-inet.c
+++ b/criu/sk-inet.c
@@ -589,8 +589,12 @@ static int open_inet_sk(struct file_desc *d)
goto err;
}
- if (restore_one_tcp(sk, ii))
+ mutex_lock(&ii->port->reuseaddr_lock);
+ if (restore_one_tcp(sk, ii)) {
+ mutex_unlock(&ii->port->reuseaddr_lock);
goto err;
+ }
+ mutex_unlock(&ii->port->reuseaddr_lock);
goto done;
}
@@ -751,8 +755,3 @@ int inet_connect(int sk, struct inet_sk_info *ii)
return 0;
}
-
-mutex_t *inet_get_reuseaddr_lock(struct inet_sk_info *ii)
-{
- return &ii->port->reuseaddr_lock;
-}
diff --git a/criu/sk-tcp.c b/criu/sk-tcp.c
index 590170a..d923db4 100644
--- a/criu/sk-tcp.c
+++ b/criu/sk-tcp.c
@@ -524,7 +524,7 @@ static int send_tcp_queue(int sk, int queue, u32 len, struct cr_img *img)
return __send_tcp_queue(sk, queue, len, img);
}
-static int restore_tcp_queues(int sk, TcpStreamEntry *tse, struct cr_img *img, mutex_t *reuse_lock)
+static int restore_tcp_queues(int sk, TcpStreamEntry *tse, struct cr_img *img)
{
u32 len;
@@ -551,17 +551,11 @@ static int restore_tcp_queues(int sk, TcpStreamEntry *tse, struct cr_img *img, m
* they can be restored without any tricks.
*/
len = tse->unsq_len;
- mutex_lock(reuse_lock);
tcp_repair_off(sk);
- if (len && __send_tcp_queue(sk, TCP_SEND_QUEUE, len, img)) {
- mutex_unlock(reuse_lock);
+ if (len && __send_tcp_queue(sk, TCP_SEND_QUEUE, len, img))
return -1;
- }
- if (tcp_repair_on(sk)) {
- mutex_unlock(reuse_lock);
+ if (tcp_repair_on(sk))
return -1;
- }
- mutex_unlock(reuse_lock);
return 0;
}
@@ -644,7 +638,7 @@ static int restore_tcp_conn_state(int sk, struct inet_sk_info *ii)
if (restore_tcp_opts(sk, tse))
goto err_c;
- if (restore_tcp_queues(sk, tse, img, inet_get_reuseaddr_lock(ii)))
+ if (restore_tcp_queues(sk, tse, img))
goto err_c;
if (tse->has_nodelay && tse->nodelay) {
--
2.5.0
More information about the CRIU
mailing list