From 91299fe1de31465b0b389ba6fee76db23db830fb Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Wed, 10 Oct 2018 00:03:59 +0200 Subject: lib: Some more fixes in retransmission The queued packets were not correctly read. The rcv_cr->seqno now indicates the next packet the receiver application expects. A lot more stable now, but still some further issues to be fixed. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/lib/frct.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/lib/frct.c') diff --git a/src/lib/frct.c b/src/lib/frct.c index 04b8a758..6041279a 100644 --- a/src/lib/frct.c +++ b/src/lib/frct.c @@ -177,10 +177,10 @@ static ssize_t __frcti_queued_pdu(struct frcti * frcti) /* See if we already have the next PDU. */ pthread_rwlock_wrlock(&frcti->lock); - pos = frcti->rcv_cr.lwe & (RQ_SIZE - 1); + pos = frcti->rcv_cr.seqno & (RQ_SIZE - 1); idx = frcti->rq[pos]; if (idx != -1) { - ++frcti->rcv_cr.lwe; + ++frcti->rcv_cr.seqno; frcti->rq[pos] = -1; } @@ -238,7 +238,7 @@ static int __frcti_snd(struct frcti * frcti, #else random_buffer(&snd_cr->seqno, sizeof(snd_cr->seqno)); #endif - frcti->snd_cr.lwe = snd_cr->seqno; + frcti->snd_cr.lwe = snd_cr->seqno - 1; } pci->seqno = hton32(snd_cr->seqno); @@ -246,7 +246,7 @@ static int __frcti_snd(struct frcti * frcti, snd_cr->lwe++; } else if (now.tv_sec - rcv_cr->act <= rcv_cr->inact) { rxmwheel_add(frcti, snd_cr->seqno, sdb); - if (rcv_cr->lwe != rcv_cr->seqno) { + if (rcv_cr->lwe <= rcv_cr->seqno) { pci->flags |= FRCT_ACK; pci->ackno = hton32(rcv_cr->seqno); rcv_cr->lwe = rcv_cr->seqno; @@ -300,7 +300,7 @@ static int __frcti_rcv(struct frcti * frcti, if (seqno == rcv_cr->seqno) { ++rcv_cr->seqno; } else { /* Out of order. */ - if ((int32_t)(seqno - rcv_cr->seqno) < 0) /* Duplicate. */ + if ((int32_t)(seqno - rcv_cr->seqno) < 0) goto drop_packet; if (rcv_cr->cflags & FRCTFRTX) { @@ -312,7 +312,7 @@ static int __frcti_rcv(struct frcti * frcti, frcti->rq[pos] = idx; ret = -EAGAIN; } else { - rcv_cr->seqno = seqno; + rcv_cr->seqno = seqno + 1; } } -- cgit v1.2.3