buglwIP - A Lightweight TCP/IP stack - Bugs: bug #59651, tcp_write() without...


You are not allowed to post comments on this tracker with your current authentication level.

bug #59651: tcp_write() without TCP_WRITE_FLAG_COPY

Submitted by:  Oleg Kobrin <kiabrin>
Submitted on:  Thu 10 Dec 2020 02:54:16 PM UTC
Category:  IPv4 Severity:  3 - Normal
Item Group:  Change Request Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open Planned Release:  None
lwIP version:  * git head
* Mandatory Fields

Add a New Comment (Rich Markup)

Comment Type & Canned Response:
       No canned response available


Fri 14 May 2021 08:26:43 AM UTC, comment #1: 

I'm not sure where the problem is. snd_buf is always increased and decreased, not depending on the copy type.

What exactly is the problem you are facing?

Simon Goldschmidt <goldsimon>
Project Administrator
Thu 10 Dec 2020 02:54:16 PM UTC, original submission:  

Debugging the code I found the problem.
Consider you have large output traffic, including one large buffer, which is used statically.
You can use double buffering to avoid modification of this buffer while it is not sent.

In call to tcp_write() you are using no TCP_WRITE_FLAG_COPY. But the pcb->snd_buf is decreased, and after some time you experiense data loss as you cannot write more data.

Obviousely, tcp_write() without TCP_WRITE_FLAG_COPY should not decrease snd_buf, as no buffer space are used. But the problem is we cannot just add

if (apiflags & TCP_WRITE_FLAG_COPY)


    pcb->snd_buf -= len;

as tcp_output() depends on this value. If where is a way to determine if nexp pbuf in unsent queue is PBUF_ROM type and not to increase snd_buf value, maybe it sould work?

Oleg Kobrin <kiabrin>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by goldsimon (Posted a comment)
  • -email is unavailable- added by kiabrin (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.





    No changes have been made to this item

    Back to the top

    Powered by Savane 3.9