mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 14:25:49 +00:00
sockets: don't double buffer size for sockets
SO_SNDBUF and SO_RCVBUF sets a double input value, because "Linux reserves half of te socket buffer for metadata." So if a process is suspended/restored many times, a socket buffer size is doubled on each iteration and in a one moment it is overflowed. Very likely the program hangs in such situation, because the socket with negative buffer size is unusable. Signed-off-by: Andrey Vagin <avagin@openvz.org> Acked-by: Cyrill Gorcunov <gorcunov@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
committed by
Pavel Emelyanov
parent
14f98abf8d
commit
1fd180ca6c
@@ -315,8 +315,13 @@ int restore_socket_opts(int sk, SkOptsEntry *soe)
|
||||
struct timeval tv;
|
||||
|
||||
pr_info("%d restore sndbuf %d rcv buf %d\n", sk, soe->so_sndbuf, soe->so_rcvbuf);
|
||||
ret |= restore_opt(sk, SOL_SOCKET, SO_SNDBUFFORCE, &soe->so_sndbuf);
|
||||
ret |= restore_opt(sk, SOL_SOCKET, SO_RCVBUFFORCE, &soe->so_rcvbuf);
|
||||
|
||||
/* setsockopt() multiplies the input values by 2 */
|
||||
val = soe->so_sndbuf / 2;
|
||||
ret |= restore_opt(sk, SOL_SOCKET, SO_SNDBUFFORCE, &val);
|
||||
val = soe->so_rcvbuf / 2;
|
||||
ret |= restore_opt(sk, SOL_SOCKET, SO_RCVBUFFORCE, &val);
|
||||
|
||||
if (soe->has_so_priority) {
|
||||
pr_debug("\trestore priority %d for socket\n", soe->so_priority);
|
||||
ret |= restore_opt(sk, SOL_SOCKET, SO_PRIORITY, &soe->so_priority);
|
||||
|
Reference in New Issue
Block a user