[OPTIM] stream_sock: do not ask for polling on EAGAIN if we have read
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.
diff --git a/src/stream_sock.c b/src/stream_sock.c
index ca2fdee..dbb60e7 100644
--- a/src/stream_sock.c
+++ b/src/stream_sock.c
@@ -229,10 +229,13 @@
}
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 {