[PATCH 1/2] wget: replace set_alarm with non blocking functions to support retries

Xabier Oneca -- xOneca xoneca at gmail.com
Thu Jan 24 09:48:50 UTC 2019


Hello Martin,

In your second patch:

> diff --git a/networking/wget.c b/networking/wget.c
> index 3df8e74..0a23e99 100644
> --- a/networking/wget.c
> +++ b/networking/wget.c
(snip)
> @@ -1295,15 +1352,22 @@ static void download_one_url(const char *url)
>              goto socket_opened;
>          }
>          sfp = open_socket(lsa);
> +        if (!sfp) {
> +            goto retry;
> +        }
>   socket_opened:
>  #elif ENABLE_FEATURE_WGET_HTTPS
>          /* Only internal TLS support is configured */
>          sfp = open_socket(lsa);
> -        if (server.protocol == P_HTTPS)
> +        if (!sfp)
> +            goto retry;
> +        if (server.protocol == P_HTTPS) {

Extra non-matched brace?

>              spawn_ssl_client(server.host, fileno(sfp), /*flags*/ 0);
>  #else
>          /* ssl (https) support is not configured */
>          sfp = open_socket(lsa);
> +        if (!sfp)
> +            goto retry;
>  #endif
>          /* Send HTTP request */
>          if (use_proxy) {
(snip)
> @@ -1531,13 +1605,18 @@ However, in real world it was observed that some web servers
>      free(lsa);
>
>      if (!(option_mask32 & WGET_OPT_SPIDER)) {
> +        int retrieve_retval;
>          if (G.output_fd < 0)
>              G.output_fd = xopen(G.fname_out, G.o_flags);
> -        retrieve_file_data(dfp);
> +                retrieve_retval = retrieve_file_data(dfp);
>          if (!(option_mask32 & WGET_OPT_OUTNAME)) {
>              xclose(G.output_fd);
>              G.output_fd = -1;
>          }
> +        if (retrieve_retval < 0) { /* We timed out, if we retry so the fd is closed */
> +                       bb_error_msg("download timed out");
> +                       goto retry;
> +               }
>      } else {
>          if (!(option_mask32 & WGET_OPT_QUIET))
>              fprintf(stderr, "remote file exists\n");

Here the indentation is mixed with spaces.

Cheers,

Xabier Oneca_,,_


More information about the busybox mailing list