Commit d5a7a1cb authored by Pavel Emelyanov's avatar Pavel Emelyanov

tcp: Send as much as possible

Don't mess with sysctl, just try sending queues in greedy mode
shrinking the max_chunk eventually.

This is needed for 2 reasons -- first, to get rig of reading the
max_rshare sysctl and to make libsoccr possible and simple.
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 72b48d27
...@@ -467,9 +467,10 @@ static int __send_tcp_queue(int sk, int queue, u32 len, struct cr_img *img) ...@@ -467,9 +467,10 @@ static int __send_tcp_queue(int sk, int queue, u32 len, struct cr_img *img)
if (read_img_buf(img, buf, len) < 0) if (read_img_buf(img, buf, len) < 0)
goto err; goto err;
max_chunk = (queue == TCP_RECV_QUEUE ? kdat.tcp_max_rshare : len); max_chunk = len;
off = 0; off = 0;
while (len) {
do {
int chunk = len; int chunk = len;
if (chunk > max_chunk) if (chunk > max_chunk)
...@@ -477,14 +478,19 @@ static int __send_tcp_queue(int sk, int queue, u32 len, struct cr_img *img) ...@@ -477,14 +478,19 @@ static int __send_tcp_queue(int sk, int queue, u32 len, struct cr_img *img)
ret = send(sk, buf + off, chunk, 0); ret = send(sk, buf + off, chunk, 0);
if (ret <= 0) { if (ret <= 0) {
if ((queue == TCP_RECV_QUEUE) && (max_chunk > 1024) && (errno == ENOMEM)) { if (max_chunk > 1024) {
/* /*
* Kernel not only refuses the whole chunk,
* but refuses to split it into pieces too.
*
* When restoring recv queue in repair mode * When restoring recv queue in repair mode
* kernel doesn't try hard and just allocates * kernel doesn't try hard and just allocates
* a linear skb with the size we pass to the * a linear skb with the size we pass to the
* system call. Thus, if the size is too big * system call. Thus, if the size is too big
* for slab allocator, the send just fails * for slab allocator, the send just fails
* with ENOMEM. Try smaller chunk, hopefully * with ENOMEM.
*
* In any case -- try smaller chunk, hopefully
* there's still enough memory in the system. * there's still enough memory in the system.
*/ */
max_chunk >>= 1; max_chunk >>= 1;
...@@ -497,7 +503,7 @@ static int __send_tcp_queue(int sk, int queue, u32 len, struct cr_img *img) ...@@ -497,7 +503,7 @@ static int __send_tcp_queue(int sk, int queue, u32 len, struct cr_img *img)
} }
off += ret; off += ret;
len -= ret; len -= ret;
} } while (len);
err = 0; err = 0;
err: err:
......
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