Piero,
It all works for me as expected.
Back then I was fighting the tcp_poll callback calling my tcp_sent function
when I wasn’t expecting it and that cascaded in several problems.
One of them was “fixed” by increasing TCP_SND_QUEUELEN. I
dropped TCP_SND_QUEUELEN to 16 and although my output is choppy, it all works
fine now.
As others have pointed out – the behavior
is correct. If data can’t be queued, something has to block until
the data can be queued. If you don’t want blocking I guess you need
to check if you can queue data before going through with the call that
blocks. Something somewhere in your program has to wait or simply drop
the outgoing data if it’s not important (e.g. status).
Bill
From:
address@hidden [mailto:address@hidden
On Behalf Of Piero 74
Sent: Wednesday, March 19, 2008
10:53 AM
To: Mailing
list for lwIP users
Subject: Re: [lwip-users]
tcp_enqueue problem, using socket:
the piece of code was
inside do_writemore function.
Bill, can you check this idea? or can you integrate here your test
tcp_accept_data
???
thanks,
Piero
2008/3/19, Piero 74 <address@hidden>:
i saw this piece of code
in tcp_write:
....
err = tcp_write(conn->pcb.tcp, dataptr, len, conn->write_msg->msg.w.apiflags);
LWIP_ASSERT("do_writemore: invalid length!",
((conn->write_offset + len) <= conn->write_msg->msg.w.len));
if (err == ERR_OK) {
conn->write_offset += len;
if (conn->write_offset ==
conn->write_msg->msg.w.len) {
/* everything was written */
write_finished = 1;
conn->write_msg = NULL;
conn->write_offset = 0;
}
err = tcp_output_nagle(conn->pcb.tcp);
conn->err = err;
if ((err == ERR_OK) && (tcp_sndbuf(conn->pcb.tcp)
<= TCP_SNDLOWAT)) {
API_EVENT(conn, NETCONN_EVT_SENDMINUS, len);
}
} else if (err == ERR_MEM) {
/* tcp_enqueue returned ERR_MEM, try tcp_output anyway */
err = tcp_output(conn->pcb.tcp);
#if LWIP_TCPIP_CORE_LOCKING
conn->write_delayed = 1;
#endif
} else {
/* if ERR_MEM, we wait for sent_tcp or poll_tcp to be
called
<--------- wrong comment??? ERR_CONN instead ERR_MEM
on other errors we don't try writing any
more */
conn->err = err;
write_finished = 1;
}
if (write_finished) {
/* everything was written: set back connection state
and back to application task */
....
first, i suppose there is a wrong comment (see above)
second, i propose a patch (but i'm not sure);
if tcp_enqueue returned ERR_MEM, instead of try tcp_output anyway, exit using
conn->err = err;
write_finished = 1;
what do you think???
Piero.
2008/3/19, Piero 74 <address@hidden>:
i didn't understand this
suggest:
#define tcp_accept_data(pcb) ((pcb)->snd_buf > 0 * (((pcb)->queuelen
< TCP_SND_QUEUELEN))
0 * (((pcb)->queuelen < TCP_SND_QUEUELEN) is always 0, right???
where have i to add this macro??
|