#ifdef SO_RCVBUF
/* For very small rate limits, set the buffer size (and hence,
hopefully, the size of the kernel window) to the size of the
- limit. */
+ limit. That way we don't sleep for more than 1s between network
+ reads. */
if (opt.limit_rate && opt.limit_rate < 8192)
{
int bufsize = opt.limit_rate;
limit_bandwidth_reset ();
wtimer_reset (timer);
- /* If we're limiting the download, set our buffer size to the
- limit. */
+ /* Use a smaller buffer for low requested bandwidths. For example,
+ with --limit-rate=2k, it doesn't make sense to slurp in 16K of
+ data and then sleep for 8s. With buffer size equal to the limit,
+ we never have to sleep for more than one second. */
if (opt.limit_rate && opt.limit_rate < dlbufsize)
dlbufsize = opt.limit_rate;