diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2011-02-11 22:01:33 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2011-02-11 22:01:33 +0100 |
commit | f9af3756687840c76d8ba4e34b33916b6e36ca61 (patch) | |
tree | eb5e724f14d3327bec15b6306598d920b2ab45ad | |
parent | 8766a791e847fdf1f3f00222f18c18833f40abda (diff) | |
download | busybox-w32-f9af3756687840c76d8ba4e34b33916b6e36ca61.tar.gz busybox-w32-f9af3756687840c76d8ba4e34b33916b6e36ca61.tar.bz2 busybox-w32-f9af3756687840c76d8ba4e34b33916b6e36ca61.zip |
wget: explain clearerr more clearly
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | networking/wget.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/networking/wget.c b/networking/wget.c index 48688640a..673113bfc 100644 --- a/networking/wget.c +++ b/networking/wget.c | |||
@@ -466,6 +466,14 @@ static void NOINLINE retrieve_file_data(FILE *dfp, int output_fd) | |||
466 | 466 | ||
467 | polldata.fd = fileno(dfp); | 467 | polldata.fd = fileno(dfp); |
468 | polldata.events = POLLIN | POLLPRI; | 468 | polldata.events = POLLIN | POLLPRI; |
469 | |||
470 | /* Must use nonblocking I/O, otherwise fread will loop | ||
471 | * and *block* until it reads full buffer, | ||
472 | * which messes up progress bar and/or timing out. | ||
473 | * Because of nonblocking I/O, we need to dance | ||
474 | * very carefully around EAGAIN. See explanation at | ||
475 | * clearerr() call. | ||
476 | */ | ||
469 | ndelay_on(polldata.fd); | 477 | ndelay_on(polldata.fd); |
470 | #endif | 478 | #endif |
471 | progress_meter(PROGRESS_START); | 479 | progress_meter(PROGRESS_START); |
@@ -504,7 +512,7 @@ static void NOINLINE retrieve_file_data(FILE *dfp, int output_fd) | |||
504 | /* Needed for "stalled" indicator */ | 512 | /* Needed for "stalled" indicator */ |
505 | progress_meter(PROGRESS_BUMP); | 513 | progress_meter(PROGRESS_BUMP); |
506 | } | 514 | } |
507 | #endif | 515 | |
508 | /* fread internally uses read loop, which in our case | 516 | /* fread internally uses read loop, which in our case |
509 | * is usually exited when we get EAGAIN. | 517 | * is usually exited when we get EAGAIN. |
510 | * In this case, libc sets error marker on the stream. | 518 | * In this case, libc sets error marker on the stream. |
@@ -515,6 +523,7 @@ static void NOINLINE retrieve_file_data(FILE *dfp, int output_fd) | |||
515 | */ | 523 | */ |
516 | clearerr(dfp); | 524 | clearerr(dfp); |
517 | errno = 0; | 525 | errno = 0; |
526 | #endif | ||
518 | n = fread(G.wget_buf, 1, rdsz, dfp); | 527 | n = fread(G.wget_buf, 1, rdsz, dfp); |
519 | /* man fread: | 528 | /* man fread: |
520 | * If error occurs, or EOF is reached, the return value | 529 | * If error occurs, or EOF is reached, the return value |