summaryrefslogtreecommitdiff
path: root/src/lib/frct.c
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri.staessens@ugent.be>2018-10-10 00:03:59 +0200
committerSander Vrijders <sander.vrijders@ugent.be>2018-10-10 09:08:34 +0200
commit91299fe1de31465b0b389ba6fee76db23db830fb (patch)
tree539ea8c17320a8cfa6bb1ffd986615cfb942ed20 /src/lib/frct.c
parent2806b069f6dd95588e31c4357548bd44a6940607 (diff)
downloadouroboros-91299fe1de31465b0b389ba6fee76db23db830fb.tar.gz
ouroboros-91299fe1de31465b0b389ba6fee76db23db830fb.zip
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 <dimitri.staessens@ugent.be> Signed-off-by: Sander Vrijders <sander.vrijders@ugent.be>
Diffstat (limited to 'src/lib/frct.c')
-rw-r--r--src/lib/frct.c12
1 files changed, 6 insertions, 6 deletions
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;
}
}