[RFC PATCH] httpd: handle HTTP upload case better
Joachim Wiberg
troglobit at gmail.com
Sat Jan 16 13:52:24 UTC 2021
On Mon, Nov 16, 2020 at 13:16, Denys Vlasenko <vda.linux at googlemail.com> wrote:
> On Sat, May 9, 2020 at 1:26 PM Joachim Nilsson <troglobit at 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.
(Worth mentioning that I wasn't the original author of this one.)
>> - shutdown(1, SHUT_WR);
>> + if (getsockopt(STDIN_FILENO, SOL_SOCKET, SO_TYPE, &t, &tl) == 0)
>> + shutdown(STDIN_FILENO, SHUT_WR);
> Why the check?
I believe the original intent was just to check if the socket was still valid.
>> - /* 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?
Unsure. Must've been an issue on the client side, because I cannot see
any problems when I try to reproduce the issue now.
Sorry for the noise, let's drop this patch.
Best regards
/Joachim
More information about the busybox
mailing list