diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2012-08-16 16:52:27 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2012-08-16 16:52:27 +0200 |
commit | 9c55143bbf4ce24bef093301e46aab15b4a71d69 (patch) | |
tree | 3707b637b2b1608f6568ce2eebb976a6c551ee62 /networking/wget.c | |
parent | 45c35e9de01010c6bb12f2b86fd5b8b31afe4617 (diff) | |
download | busybox-w32-9c55143bbf4ce24bef093301e46aab15b4a71d69.tar.gz busybox-w32-9c55143bbf4ce24bef093301e46aab15b4a71d69.tar.bz2 busybox-w32-9c55143bbf4ce24bef093301e46aab15b4a71d69.zip |
wget: try reading after poll timeout - stdio may have buffered data. Closes 5426
function old new delta
retrieve_file_data 436 451 +15
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/wget.c')
-rw-r--r-- | networking/wget.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/networking/wget.c b/networking/wget.c index 6d8f8a504..3416636ae 100644 --- a/networking/wget.c +++ b/networking/wget.c | |||
@@ -448,6 +448,9 @@ static void NOINLINE retrieve_file_data(FILE *dfp) | |||
448 | # endif | 448 | # endif |
449 | struct pollfd polldata; | 449 | struct pollfd polldata; |
450 | 450 | ||
451 | # if ENABLE_FEATURE_WGET_TIMEOUT | ||
452 | second_cnt = G.timeout_seconds; | ||
453 | # endif | ||
451 | polldata.fd = fileno(dfp); | 454 | polldata.fd = fileno(dfp); |
452 | polldata.events = POLLIN | POLLPRI; | 455 | polldata.events = POLLIN | POLLPRI; |
453 | #endif | 456 | #endif |
@@ -483,12 +486,7 @@ static void NOINLINE retrieve_file_data(FILE *dfp) | |||
483 | } | 486 | } |
484 | 487 | ||
485 | #if ENABLE_FEATURE_WGET_STATUSBAR || ENABLE_FEATURE_WGET_TIMEOUT | 488 | #if ENABLE_FEATURE_WGET_STATUSBAR || ENABLE_FEATURE_WGET_TIMEOUT |
486 | # if ENABLE_FEATURE_WGET_TIMEOUT | 489 | if (safe_poll(&polldata, 1, 1000) == 0) { |
487 | second_cnt = G.timeout_seconds; | ||
488 | # endif | ||
489 | while (1) { | ||
490 | if (safe_poll(&polldata, 1, 1000) != 0) | ||
491 | break; /* error, EOF, or data is available */ | ||
492 | # if ENABLE_FEATURE_WGET_TIMEOUT | 490 | # if ENABLE_FEATURE_WGET_TIMEOUT |
493 | if (second_cnt != 0 && --second_cnt == 0) { | 491 | if (second_cnt != 0 && --second_cnt == 0) { |
494 | progress_meter(PROGRESS_END); | 492 | progress_meter(PROGRESS_END); |
@@ -497,6 +495,13 @@ static void NOINLINE retrieve_file_data(FILE *dfp) | |||
497 | # endif | 495 | # endif |
498 | /* Needed for "stalled" indicator */ | 496 | /* Needed for "stalled" indicator */ |
499 | progress_meter(PROGRESS_BUMP); | 497 | progress_meter(PROGRESS_BUMP); |
498 | /* | ||
499 | * We used to loop back to poll here, | ||
500 | * but in chunked case, we can be here after | ||
501 | * fgets and it could buffer some data in dfp... | ||
502 | * which poll knows nothing about! | ||
503 | * Therefore let's try fread'ing anyway. | ||
504 | */ | ||
500 | } | 505 | } |
501 | 506 | ||
502 | /* fread internally uses read loop, which in our case | 507 | /* fread internally uses read loop, which in our case |
@@ -527,7 +532,9 @@ static void NOINLINE retrieve_file_data(FILE *dfp) | |||
527 | } | 532 | } |
528 | 533 | ||
529 | xwrite(G.output_fd, G.wget_buf, n); | 534 | xwrite(G.output_fd, G.wget_buf, n); |
530 | 535 | #if ENABLE_FEATURE_WGET_TIMEOUT | |
536 | second_cnt = G.timeout_seconds; | ||
537 | #endif | ||
531 | #if ENABLE_FEATURE_WGET_STATUSBAR | 538 | #if ENABLE_FEATURE_WGET_STATUSBAR |
532 | G.transferred += n; | 539 | G.transferred += n; |
533 | progress_meter(PROGRESS_BUMP); | 540 | progress_meter(PROGRESS_BUMP); |