lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] [PATCH] Fix a racing codition in tcp_output()


From: Roy Lee
Subject: [lwip-users] [PATCH] Fix a racing codition in tcp_output()
Date: Tue, 14 Apr 2009 08:37:51 +0800

From: Roy Lee <address@hidden>

Sending a segment before it is added to the unacked list may result
a racing problem when it's ack is received before it got added to the
list.
---
 src/core/tcp_out.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/core/tcp_out.c b/src/core/tcp_out.c
index 653ce4a..6b89596 100644
--- a/src/core/tcp_out.c
+++ b/src/core/tcp_out.c
@@ -573,7 +573,6 @@ tcp_output(struct tcp_pcb *pcb)
      pcb->flags &= ~(TF_ACK_DELAY | TF_ACK_NOW);
    }

-    tcp_output_segment(seg, pcb);
    pcb->snd_nxt = ntohl(seg->tcphdr->seqno) + TCP_TCPLEN(seg);
    if (TCP_SEQ_LT(pcb->snd_max, pcb->snd_nxt)) {
      pcb->snd_max = pcb->snd_nxt;
@@ -600,8 +599,10 @@ tcp_output(struct tcp_pcb *pcb)
          useg = useg->next;
        }
      }
-    /* do not queue empty segments on the unacked list */
-    } else {
+    }
+
+    tcp_output_segment(seg, pcb);
+    if (TCP_TCPLEN(seg) == 0) {
      tcp_seg_free(seg);
    }
    seg = pcb->unsent;
--
1.6.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]