dns: Fix dns_alloc_pcb for reuse an existing one case

The logic to use an already existing pcb is wrong because the idx never
advanced in the for loop, so it keep checking the same dns_pcbs[idx] for
each loop iteration. Fix it.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
This commit is contained in:
Axel Lin 2015-11-13 16:01:38 +08:00 committed by goldsimon
parent 29553ba7a1
commit 668d461104

View File

@ -851,8 +851,7 @@ dns_alloc_pcb(void)
} }
/* if we come here, creating a new UDP pcb failed, so we have to use /* if we come here, creating a new UDP pcb failed, so we have to use
an already existing one */ an already existing one */
idx = dns_last_pcb_idx + 1; for (i = 0, idx = dns_last_pcb_idx + 1; i < DNS_MAX_SOURCE_PORTS; i++, idx++) {
for (i = 0; i < DNS_MAX_SOURCE_PORTS; i++) {
if (idx >= DNS_MAX_SOURCE_PORTS) { if (idx >= DNS_MAX_SOURCE_PORTS) {
idx = 0; idx = 0;
} }