Simplify testing minimum priority in tcp_kill_prio()

Simplify the code a bit by setting mprio = LWIP_MIN(TCP_PRIO_MAX, prio)
before the for loop.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
This commit is contained in:
Axel Lin 2015-11-19 20:59:54 +08:00 committed by sg
parent c730e45f0c
commit f971fb921e

View File

@ -1331,14 +1331,13 @@ tcp_kill_prio(u8_t prio)
u32_t inactivity; u32_t inactivity;
u8_t mprio; u8_t mprio;
mprio = TCP_PRIO_MAX; mprio = LWIP_MIN(TCP_PRIO_MAX, prio);
/* We kill the oldest active connection that has lower priority than prio. */ /* We kill the oldest active connection that has lower priority than prio. */
inactivity = 0; inactivity = 0;
inactive = NULL; inactive = NULL;
for (pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next) { for (pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next) {
if (pcb->prio <= prio && if (pcb->prio <= mprio &&
pcb->prio <= mprio &&
(u32_t)(tcp_ticks - pcb->tmr) >= inactivity) { (u32_t)(tcp_ticks - pcb->tmr) >= inactivity) {
inactivity = tcp_ticks - pcb->tmr; inactivity = tcp_ticks - pcb->tmr;
inactive = pcb; inactive = pcb;