[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-devel] Re: [task #7040] Work on tcp_enqueue
From: |
Jakob Stoklund Olesen |
Subject: |
[lwip-devel] Re: [task #7040] Work on tcp_enqueue |
Date: |
Sun, 01 Feb 2009 14:01:38 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) |
"address@hidden" <address@hidden> writes:
> Jakob Stoklund Olesen wrote:
>> [... tcp_sent_callback() ...]
>> It worked most of the time, but TCP retransmissions caused bad stuff to
>> happen. It was either a bug in my code, or the sum of callback lengths
>> did not match what had been actually sent.
>>
>> Has anybody used non-copy tcp_write with memory that must be reclaimed?
>> Can it be done?
>
> I suppose that could be a bug in tcp_sent_callback. I've never tested
> it, but I always expected it to be called when data has been ACKed
> (which means it should not be retransmitted again). If so,
> retransmission should not have an impact.
I remember looking at tcp_in.c and getting confused. There are two
crucial spots:
in tcp_input():
TCP_EVENT_SENT(pcb, pcb->acked, err);
in tcp_receive():
pcb->acked = (u16_t)(ackno - pcb->lastack);
pcb->snd_buf += pcb->acked;
I was not completely sure if these two places in the code are always
executed 'in sync' so that every update to pcb->acked / pcb_snd_buf
results in exactly one call to TCP_EVENT_SENT.
If my original understanding of TCP_EVENT_SENT was right, this would be
the best way of supporting zero-copy TCP, IMHO. Yes, it requires a bit
more bookkeeping outside the stack, but it is so much more flexible than
passing in magic pbufs.
You could implement the Posix AIO interface this way: "Please send this
random chunk of data, and tell me when you're done with it."
/stoklund