|
From: | Tony |
Subject: | Re: [lwip-users] Limiting the number of connections: Possible bug with MEMP_NUM_TCP_PCB? |
Date: | Fri, 4 Aug 2017 10:54:29 +0200 |
Tony wrote:
The aim is to only allow n open TCP connection at a time, and reject all further connection requests. This worked reasonably well in 1.3.2, but now fails in 2.0.2.
[..]
HOWEVER: this n+1 connection terminates the very 1st connection (takes over the 1st PCB?).
Although it's strange it's like that, this is expected behaviour of tcp_alloc(). I compared 2.0.2 to 1.3.2 and I don't really see a difference though...
Anyway, the pcb limitation might not be the correct solution. A listen backlog might better do what you want.
If you want to stay with your pcb limitation, try calling "tcp_setprio(newpcb, TCP_PRIO_MAX);" after you allocate the first n pcbs. That should prevent tcp_alloc from reusing them.
Now, if I leave all previous connections open and make a n+1 connection (the 6th connection in this example) I hit an exception (the processor tries to access memory that does not exists and I hit the exception handler in the MCU).
I narrowed down the origin of the fatal exception in tcp_alloc() to the code following this comment:
/* zero out the whole pcb, so there is no need to initialize members to zero */
The problem at that point seems to be that a struct tcp_pcb_listen (that is still in use) is reused and overwritten as a struct tcp_pcb...
Ehrm, the pcb that is used there should *NOT* be a listen pcb. It comes from the MEMP_TCP_PCB pool, so it's a standard pcb. Why do you think it's a listen pcb which is still in use? This lets me think you have a port problem...
[Prev in Thread] | Current Thread | [Next in Thread] |