lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-devel] [bug #46289] tcp_write fails with ERR_MEM if TCP_SND_QUEUEL


From: Ambroz Bizjak
Subject: [lwip-devel] [bug #46289] tcp_write fails with ERR_MEM if TCP_SND_QUEUELEN is reached
Date: Sun, 25 Oct 2015 08:23:15 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36

URL:
  <http://savannah.nongnu.org/bugs/?46289>

                 Summary: tcp_write fails with ERR_MEM if TCP_SND_QUEUELEN is
reached
                 Project: lwIP - A Lightweight TCP/IP stack
            Submitted by: abizjak
            Submitted on: Sun 25 Oct 2015 08:23:14 AM GMT
                Category: IPv4
                Severity: 3 - Normal
              Item Group: Faulty Behaviour
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: 
            lwIP version: git head

    _______________________________________________________

Details:

If tcp_write() is called many times with small chunks of data and tcp_output()
calls in between, the maximum allowed number of queued pbufs
(TCP_SND_QUEUELEN) will be reached and tcp_write() calls will start failing
with ERR_MEM.

I'm aware that the application can react to this by retrying tcp_write() after
receiving a tcp_sent callback. However this is not optimal, because the
failing tcp_write() call could have written some data - perhaps only the last
few bytes of the given buffer didn't fit. Additionally, it is not possible for
the application to distinguish between hitting the TCP_SND_QUEUELEN limit from
otherwise running out of memory (other places where ERR_MEM is returned) which
is more serious and may warrant closing the connection.

I provide a patch which implements a partial-write feature in tcp_write
(actually I rename that to tcp_write_ext()). When using this
TCP_WRITE_FLAG_PARTIAL, tcp_write_ext() will not consider hitting the
TCP_SND_QUEUELEN an error, but it will write whatever was possible until the
limit is reached. The number of bytes written will be made available to the
user.



    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Sun 25 Oct 2015 08:23:14 AM GMT  Name: lwip-partial-write.patch  Size:
6kB   By: abizjak
Implementation of partial TCP writes.
<http://savannah.nongnu.org/bugs/download.php?file_id=35283>

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?46289>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]