]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[OPTIM] stream_sock: do not ask for polling on EAGAIN if we have read
authorWilly Tarreau <w@1wt.eu>
Thu, 8 Jan 2009 09:09:08 +0000 (10:09 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 9 Jan 2009 09:15:03 +0000 (10:15 +0100)
It is not always wise to return 0 in stream_sock_read() upon EAGAIN,
because if we have read enough data, we should consider that enough
and try again later without polling in between.

We still make a difference between small reads and large reads though.
Small reads still lead to polling because we're sure that there's
nothing left in the system's buffers if we read less than one MSS.

src/stream_sock.c

index ca2fdee7343cee318494a8c3cccb1d76ca99b5bd..dbb60e7d11cd7a462fa46dd4a375661838f3f90c 100644 (file)
@@ -229,10 +229,13 @@ int stream_sock_read(int fd) {
                }
                else if (errno == EAGAIN) {
                        /* Ignore EAGAIN but inform the poller that there is
-                        * nothing to read left. But we may have done some work
-                        * justifying to notify the task.
+                        * nothing to read left if we did not read much, ie
+                        * less than what we were still expecting to read.
+                        * But we may have done some work justifying to notify
+                        * the task.
                         */
-                       retval = 0;
+                       if (cur_read < MIN_RET_FOR_READ_LOOP)
+                               retval = 0;
                        break;
                }
                else {