[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-users] TCP fragmentation over PPP - fragments are lost in LwIP
From: |
Simon Goldschmidt |
Subject: |
Re: [lwip-users] TCP fragmentation over PPP - fragments are lost in LwIP if data is queued for sending |
Date: |
Mon, 28 Nov 2016 12:29:38 +0100 |
Marco Jakobs wrote:
> We're not using nonblocking connections as this never did work properly … in
> my today's
> debug session I've found why. In api_lib.c, line 610 this code just prevents
> using
> NETCONN_WRITE for nonblocking connections:
>
> dontblock = netconn_is_nonblocking(conn) || (apiflags & NETCONN_DONTBLOCK);
> if (dontblock && !bytes_written) {
> /* This implies netconn_write() cannot be used for non-blocking send, since
> it has no way to return the number of bytes written. */
> return ERR_VAL;
> }
This code is correct. You're just using the wrong function. For nonblocking,
you need to
use 'netconn_write_partly()' instead of 'netconn_write()'. This ensures you get
the number
of actually written bytes - as you saw, ERR_OK can be returned without all
bytes written.
Returning ERR_WOULDBLOCK is not a solution as some bytes are already written
(in that case at least).
The above code is simply missing a check for send-timeout. Using send-timeout
without passing
a 'bytes_written' pointer (or using 'netconn_write()' instead of
'netconn_write_partly()'),
does not work (for the reason described above). So the bug you found is that
this check is missing.
> [..]
> Giving back an ERR_OK where data is definitely lost is clearly a bug,
Yes. I'll add the check that nonblocking write needs a 'bytes_left' pointer,
too. Thanks for
tracking that down.
> so as a solution we've changed the SNDTIMEO handling in do_writemore in this
> way:
Congrats, with this change, you effectively turned send-timeout into
nonblocking ;-)
Simon