[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-users] lwip-users Digest, Vol 162, Issue 1
From: |
Axel Lin |
Subject: |
Re: [lwip-users] lwip-users Digest, Vol 162, Issue 1 |
Date: |
Fri, 3 Feb 2017 12:48:32 +0800 |
2017-02-03 3:41 GMT+08:00 address@hidden <address@hidden>:
> Sandra Gilge (ADATIS) wrote:
>>>
>>> Simon wrote
>>> I'm not sure I get it. You checked that sockets are used from only one
>>> thread? The thing to check >would be to ensure that *every* core function
>>> (not sockets) is only called from tcpip_thread and not >from an interrupt.
>>> That would indeed be useful for debugging. I could imagine adding a macro
>>> for this >which whould need to be implemented by an lwIP port.
>>
>> I did both. In the core functions I compare the calling thread with the
>> tcpip thread ID.
>> In the sockets I store for each socket created with socket or accept the
>> thread that created the socket and compare it in the other socket functions
>> with the calling thread ID. So I can be shure that a single socket is not
>> "used" by different threads (i.e. select in one and send in the other). At
>> least in the past things like that caused problems.
>
>
> Right. In that case I'd be *very* happy to hear what caused the memp
> overflow - and the TCP_OVERSIZE error, too, of course (TCP_OVERSIZE worked
> for me up to now, but that doesn't mean there's no bug).
It seems possible to hit "unsent_oversize mismatch (pcb vs.
last_unsent)" if tcp_output_segment() fails.
I'm wondering if below change make sense? (I don't have a device handy
to test today, so not test yet).
diff --git a/src/core/tcp_out.c b/src/core/tcp_out.c
index 108028b..cfd0127 100644
--- a/src/core/tcp_out.c
+++ b/src/core/tcp_out.c
@@ -1108,15 +1108,15 @@ tcp_output(struct tcp_pcb *pcb)
TCPH_SET_FLAG(seg->tcphdr, TCP_ACK);
}
-#if TCP_OVERSIZE_DBGCHECK
- seg->oversize_left = 0;
-#endif /* TCP_OVERSIZE_DBGCHECK */
err = tcp_output_segment(seg, pcb, netif);
if (err != ERR_OK) {
/* segment could not be sent, for whatever reason */
pcb->flags |= TF_NAGLEMEMERR;
return err;
}
+#if TCP_OVERSIZE_DBGCHECK
+ seg->oversize_left = 0;
+#endif /* TCP_OVERSIZE_DBGCHECK */
pcb->unsent = seg->next;
if (pcb->state != SYN_SENT) {
pcb->flags &= ~(TF_ACK_DELAY | TF_ACK_NOW);