[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: [RFC PATCH] httpd: handle HTTP upload case better
From:       Denys Vlasenko <vda.linux () googlemail ! com>
Date:       2020-11-16 12:16:15
Message-ID: CAK1hOcPm8C76mZdiLCTR82EO26Db8Ca6M08+1p1+3hZ2OWG3-w () mail ! gmail ! com
[Download RAW message or body]

On Sat, May 9, 2020 at 1:26 PM Joachim Nilsson <troglobit@gmail.com> wrote:
> When shutting down a connection right after an HTTP upload we must wait
> a while for the client to see the response.
>
> Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
> ---
>  networking/httpd.c | 15 +++++++++------
>  1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/networking/httpd.c b/networking/httpd.c
> index c2d226592..6993dcbf3 100644
> --- a/networking/httpd.c
> +++ b/networking/httpd.c
> @@ -1014,15 +1014,18 @@ static int openServer(void)
>  static void log_and_exit(void) NORETURN;
>  static void log_and_exit(void)
>  {
> +       int t;
> +       socklen_t tl = sizeof(t);
> +
>         /* Paranoia. IE said to be buggy. It may send some extra data
>          * or be confused by us just exiting without SHUT_WR. Oh well. */
> -       shutdown(1, SHUT_WR);
> +       if (getsockopt(STDIN_FILENO, SOL_SOCKET, SO_TYPE, &t, &tl) == 0)
> +               shutdown(STDIN_FILENO, SHUT_WR);

Why the check?

> -       /* Why??
> -       (this also messes up stdin when user runs httpd -i from terminal)
> -       ndelay_on(0);
> -       while (read(STDIN_FILENO, iobuf, IOBUF_SIZE) > 0)
> +
> +       /* Eat any remaining data for a while to allow response to be seen */
> +       alarm(30);
> +       while (recv(STDIN_FILENO, iobuf, IOBUF_SIZE, MSG_DONTWAIT) > 0)
>                 continue;
> -       */

What happens on tcpdump level if this is not done?
IOW:
_How exactly_ the client gets confused? Is it getting TCP RST packet when
we exit and thus implicitly close the socket?
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic