[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-users] tcp_output() when processing "tcp_input_pcb"
From: |
Valery Ushakov |
Subject: |
Re: [lwip-users] tcp_output() when processing "tcp_input_pcb" |
Date: |
Mon, 12 Aug 2013 19:39:48 +0000 (UTC) |
User-agent: |
tin/2.0.1-20111224 ("Achenvoir") (UNIX) (NetBSD/6.1_RC1 (macppc)) |
Numb_Faith <address@hidden> wrote:
> When I use lwip1.4.1 and RAW API, I meet a problem. I use my borad(STM32) as
> a server. When server receive a packet from client, I hope it can send a
> packet immediately. So I call the function below:
>
> /tcp_write(tpcb, DataTest, sizeof(DataTest), 0x01);
> tcp_output(tpcb);/
>
> But when server receive a packet, the stack will call tcp_input(), and
> tcp_input_pcb = pcb (the connection), so tcp_output(tpcb) would return.
>
> When I comment the code below(in function tcp_output), it can got what I
> want. But I'm still confused about why "If we are invoked by the TCP input
> processing code, we do not output anything".
>
> /* First, check if we are invoked by the TCP input processing code. If so,
> we do not output anything.
> Instead, we rely on the input processing code to call us when input
> processing is done with. */
> // if (tcp_input_pcb == pcb) {
> // return ERR_OK;
> // }
Input processing code _does_ call tcp_output() at:
http://git.savannah.gnu.org/cgit/lwip.git/tree/src/core/tcp_in.c?h=DEVEL-1_4_1#n381
tcp_input_pcb = NULL;
/* Try to send something out. */
tcp_output(pcb);
At that point input processing is complete and pcb is in consistent
state, etc, etc, so tcp_output() doesn't have to be concerned with
possible iteractions with tcp_input().
-uwe