OPTIM: stream_sock: save a failed recv syscall when splice returns EAGAIN
authorWilly Tarreau <w@1wt.eu>
Sun, 11 Dec 2011 21:37:06 +0000 (22:37 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 11 Dec 2011 23:03:55 +0000 (00:03 +0100)
commit82a04566ecbb3e8e01b657240d5031e5faa1310e
treea04b4230b171acedf224cc5a6ecaaaafad87a8ea
parenteb9fd5178e73bf1204a37e7b99edf6c9ccdb4bdd
OPTIM: stream_sock: save a failed recv syscall when splice returns EAGAIN

When splice() returns EAGAIN, on old kernels it could be caused by a read
shutdown which was not detected. Due to this behaviour, we had to fall
back to recv(), which in turn says if it's a real EAGAIN or a shutdown.
Since this behaviour was fixed in 2.6.27.14, on more recent kernels we'd
prefer to avoid the fallback to recv() when possible. For this, we set a
variable the first time splice() detects a shutdown, to indicate that it
works. We can then rely on this variable to adjust our behaviour.

Doing this alone increased the overall performance by about 1% on medium
sized objects.
src/stream_sock.c