polldata.fd = fileno(dfp);
polldata.events = POLLIN | POLLPRI;
+
+ /* Must use nonblocking I/O, otherwise fread will loop
+ * and *block* until it reads full buffer,
+ * which messes up progress bar and/or timing out.
+ * Because of nonblocking I/O, we need to dance
+ * very carefully around EAGAIN. See explanation at
+ * clearerr() call.
+ */
ndelay_on(polldata.fd);
#endif
progress_meter(PROGRESS_START);
/* Needed for "stalled" indicator */
progress_meter(PROGRESS_BUMP);
}
-#endif
+
/* fread internally uses read loop, which in our case
* is usually exited when we get EAGAIN.
* In this case, libc sets error marker on the stream.
*/
clearerr(dfp);
errno = 0;
+#endif
n = fread(G.wget_buf, 1, rdsz, dfp);
/* man fread:
* If error occurs, or EOF is reached, the return value