diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2011-02-11 22:23:23 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2011-02-11 22:23:23 +0100 |
commit | c60f4460bb3f53c5cfcfd01c99a50eb9ae69f8aa (patch) | |
tree | ed3bebbfa895bd0ab9863967fc3d3afc3db8b41e /networking/wget.c | |
parent | f9af3756687840c76d8ba4e34b33916b6e36ca61 (diff) | |
download | busybox-w32-c60f4460bb3f53c5cfcfd01c99a50eb9ae69f8aa.tar.gz busybox-w32-c60f4460bb3f53c5cfcfd01c99a50eb9ae69f8aa.tar.bz2 busybox-w32-c60f4460bb3f53c5cfcfd01c99a50eb9ae69f8aa.zip |
wget: chunked mode fix. Closes bug 3229
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/wget.c')
-rw-r--r-- | networking/wget.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/networking/wget.c b/networking/wget.c index 673113bfc..4ef5900cb 100644 --- a/networking/wget.c +++ b/networking/wget.c | |||
@@ -466,15 +466,6 @@ 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 | */ | ||
477 | ndelay_on(polldata.fd); | ||
478 | #endif | 469 | #endif |
479 | progress_meter(PROGRESS_START); | 470 | progress_meter(PROGRESS_START); |
480 | 471 | ||
@@ -483,6 +474,17 @@ static void NOINLINE retrieve_file_data(FILE *dfp, int output_fd) | |||
483 | 474 | ||
484 | /* Loops only if chunked */ | 475 | /* Loops only if chunked */ |
485 | while (1) { | 476 | while (1) { |
477 | |||
478 | #if ENABLE_FEATURE_WGET_STATUSBAR || ENABLE_FEATURE_WGET_TIMEOUT | ||
479 | /* Must use nonblocking I/O, otherwise fread will loop | ||
480 | * and *block* until it reads full buffer, | ||
481 | * which messes up progress bar and/or timeout logic. | ||
482 | * Because of nonblocking I/O, we need to dance | ||
483 | * very carefully around EAGAIN. See explanation at | ||
484 | * clearerr() call. | ||
485 | */ | ||
486 | ndelay_on(polldata.fd); | ||
487 | #endif | ||
486 | while (1) { | 488 | while (1) { |
487 | int n; | 489 | int n; |
488 | unsigned rdsz; | 490 | unsigned rdsz; |
@@ -552,11 +554,15 @@ static void NOINLINE retrieve_file_data(FILE *dfp, int output_fd) | |||
552 | break; | 554 | break; |
553 | } | 555 | } |
554 | } | 556 | } |
557 | #if ENABLE_FEATURE_WGET_STATUSBAR || ENABLE_FEATURE_WGET_TIMEOUT | ||
558 | clearerr(dfp); | ||
559 | ndelay_off(polldata.fd); | ||
560 | #endif | ||
555 | 561 | ||
556 | if (!G.chunked) | 562 | if (!G.chunked) |
557 | break; | 563 | break; |
558 | 564 | ||
559 | fgets_and_trim(dfp); /* This is a newline */ | 565 | fgets_and_trim(dfp); /* Eat empty line */ |
560 | get_clen: | 566 | get_clen: |
561 | fgets_and_trim(dfp); | 567 | fgets_and_trim(dfp); |
562 | G.content_len = STRTOOFF(G.wget_buf, NULL, 16); | 568 | G.content_len = STRTOOFF(G.wget_buf, NULL, 16); |