Suggest, try to run you same application with this issue on Linux.

I'm expecting at least a similar error on Linux.

BR,

Alan

On 6/18/23, Alan C. Assis <acas...@gmail.com> wrote:
> Hi Fotis,
>
> On 6/18/23, Fotis Panagiotopoulos <f.j.pa...@gmail.com> wrote:
>> Hello,
>>
>> Due to a bug in my application, the code tried to use sendfile() with
>> zero
>> size.
>>
>> As I see, sendfile() will happily proceed, and it will block here:
>> https://github.com/apache/nuttx/blob/master/net/tcp/tcp_sendfile.c#L523
>>
>> Obviously, it will never manage to send any data (as the requested size
>> is
>> 0),
>> and after the timeout expires, it will return EAGAIN.
>>
>
> Good finding!
>
> BTW, that is the default timeout value?
>
> I think conn->sconn.s_sndtimeo is only defined when people enable the
> CONFIG_NET_SOCKOPTS.
>
>> This seems a bit wrong to me.
>> Why not return immediately, but instead wait for the (inevitable)
>> timeout?
>> Why not return a more meaningful error code, or maybe just 0?
>>
>
> I was going to suggest avoid sending a packet with 0 byte, but it is
> supported:
> https://www.quora.com/Can-TCP-send-0-byte-packets
> https://github.com/golang/go/issues/10940
>
> See, technically it is not an error! :-)
>
>> I couldn't find what the standards dictate for this edge case, so maybe
>> the
>> current behavior is correct.
>>
>> What do you think?
>>
>
> I think it is correct, but most servers will just ignore it and you
> will end-up with a timeout.
>
> BR,
>
> Alan
>

Reply via email to