|
|
|
@ -103,7 +103,7 @@ struct lwip_tcp_ctx *lwip_tcp_init(struct UASYNC *ua, tcp_output_fn output, void |
|
|
|
return NULL; |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
ctx->iss_seed = (uint16_t)(get_time_tb() & 0xFFFF); |
|
|
|
ctx->iss_seed = (uint16_t)(get_time_tb() & 0xFFFF); |
|
|
|
ctx->tmr_interval_ms = TCP_TMR_INTERVAL; |
|
|
|
ctx->tmr_interval_ms = TCP_TMR_INTERVAL / 4; |
|
|
|
ctx->rto_min_ms = 3000; |
|
|
|
ctx->rto_min_ms = 3000; |
|
|
|
ctx->rto_max_ms = 0; |
|
|
|
ctx->rto_max_ms = 0; |
|
|
|
ctx->timer = uasync_set_timeout(ua, ctx->tmr_interval_ms * 10, ctx, tcp_tmr_cb, "lwip_tcp_tmr"); |
|
|
|
ctx->timer = uasync_set_timeout(ua, ctx->tmr_interval_ms * 10, ctx, tcp_tmr_cb, "lwip_tcp_tmr"); |
|
|
|
@ -749,7 +749,6 @@ void tcp_slowtmr(struct lwip_tcp_ctx *ctx) |
|
|
|
tcp_pcb_purge(pcb); |
|
|
|
tcp_pcb_purge(pcb); |
|
|
|
if (prev != NULL) { |
|
|
|
if (prev != NULL) { |
|
|
|
prev->next = pcb->next; |
|
|
|
prev->next = pcb->next; |
|
|
|
prev->next_owner = PCB_NEXT_SLOWTMR; |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
ctx->active_pcbs = pcb->next; |
|
|
|
ctx->active_pcbs = pcb->next; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -808,18 +807,16 @@ void tcp_slowtmr(struct lwip_tcp_ctx *ctx) |
|
|
|
tcp_pcb_purge(pcb); |
|
|
|
tcp_pcb_purge(pcb); |
|
|
|
if (prev != NULL) { |
|
|
|
if (prev != NULL) { |
|
|
|
prev->next = pcb->next; |
|
|
|
prev->next = pcb->next; |
|
|
|
prev->next_owner = PCB_NEXT_SLOWTMR; |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
ctx->tw_pcbs = pcb->next; |
|
|
|
ctx->tw_pcbs = pcb->next; |
|
|
|
} |
|
|
|
} |
|
|
|
pcb2 = pcb; |
|
|
|
pcb2 = pcb; |
|
|
|
pcb = pcb->next; |
|
|
|
pcb = pcb->next; |
|
|
|
int self_loop = (pcb == pcb2); |
|
|
|
int self_loop = (pcb == pcb2); |
|
|
|
uint8_t sl_owner = pcb2->next_owner; |
|
|
|
|
|
|
|
tcp_free(pcb2); |
|
|
|
tcp_free(pcb2); |
|
|
|
if (self_loop) { |
|
|
|
if (self_loop) { |
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_ALL, "TW_PCBS SELF-LOOP in tcp_slowtmr: freed pcb=%p state=TIME_WAIT port=%u next_owner=%d, clearing tw_pcbs", |
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_ALL, "TW_PCBS SELF-LOOP in tcp_slowtmr: freed pcb=%p state=TIME_WAIT port=%u, clearing tw_pcbs", |
|
|
|
(void*)pcb2, pcb2->local_port, sl_owner); |
|
|
|
(void*)pcb2, pcb2->local_port); |
|
|
|
ctx->tw_pcbs = NULL; |
|
|
|
ctx->tw_pcbs = NULL; |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -1050,8 +1047,8 @@ static void tcp_kill_timewait(struct lwip_tcp_ctx *ctx) |
|
|
|
} |
|
|
|
} |
|
|
|
if (inactive != NULL) { |
|
|
|
if (inactive != NULL) { |
|
|
|
if (inactive->next == inactive) { |
|
|
|
if (inactive->next == inactive) { |
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_ALL, "TW_PCBS SELF-LOOP in tcp_kill_timewait: aborting pcb=%p next_owner=%d, clearing tw_pcbs", |
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_ALL, "TW_PCBS SELF-LOOP in tcp_kill_timewait: aborting pcb=%p, clearing tw_pcbs", |
|
|
|
(void*)inactive, inactive->next_owner); |
|
|
|
(void*)inactive); |
|
|
|
ctx->tw_pcbs = NULL; |
|
|
|
ctx->tw_pcbs = NULL; |
|
|
|
tcp_free(inactive); |
|
|
|
tcp_free(inactive); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
@ -1115,8 +1112,8 @@ struct tcp_pcb *tcp_alloc(struct lwip_tcp_ctx *ctx, uint8_t prio) |
|
|
|
pcb->rcv_wnd = pcb->rcv_ann_wnd = TCPWND16(TCP_WND); |
|
|
|
pcb->rcv_wnd = pcb->rcv_ann_wnd = TCPWND16(TCP_WND); |
|
|
|
pcb->ttl = 64; |
|
|
|
pcb->ttl = 64; |
|
|
|
pcb->mss = INITIAL_MSS; |
|
|
|
pcb->mss = INITIAL_MSS; |
|
|
|
pcb->rto = (int16_t)(ctx->rto_min_ms / TCP_SLOW_INTERVAL); |
|
|
|
pcb->rto = (int16_t)(TCP_RTO_MIN_MS / TCP_SLOW_INTERVAL); |
|
|
|
pcb->sv = (int16_t)(ctx->rto_min_ms / TCP_SLOW_INTERVAL); |
|
|
|
pcb->sv = (int16_t)(TCP_RTO_MIN_MS / TCP_SLOW_INTERVAL); |
|
|
|
pcb->rtime = -1; |
|
|
|
pcb->rtime = -1; |
|
|
|
pcb->cwnd = 1; |
|
|
|
pcb->cwnd = 1; |
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_GENERAL, "tcp_alloc: cwnd=%u snd_buf=%u mss=%u snd_wnd=%u", pcb->cwnd, pcb->snd_buf, pcb->mss, pcb->snd_wnd); |
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_GENERAL, "tcp_alloc: cwnd=%u snd_buf=%u mss=%u snd_wnd=%u", pcb->cwnd, pcb->snd_buf, pcb->mss, pcb->snd_wnd); |
|
|
|
|