summaryrefslogtreecommitdiff
path: root/code/core
diff options
context:
space:
mode:
Diffstat (limited to 'code/core')
-rw-r--r--code/core/core.c1
-rw-r--r--code/core/rbuf_recv.c10
2 files changed, 5 insertions, 6 deletions
diff --git a/code/core/core.c b/code/core/core.c
index ab4041f..fafda4f 100644
--- a/code/core/core.c
+++ b/code/core/core.c
@@ -1349,6 +1349,7 @@ int ecp_msg_defrag(ECPFragIter *iter, ecp_seq_t seq, unsigned char *msg_in, size
} else {
if (iter->seq + frag_cnt != seq) {
iter->seq = seq - frag_cnt;
+ iter->frag_cnt = 0;
return ECP_ERR_ITER;
}
if (iter->frag_cnt != frag_cnt) return ECP_ERR_ITER;
diff --git a/code/core/rbuf_recv.c b/code/core/rbuf_recv.c
index 2217bfc..b3b48dc 100644
--- a/code/core/rbuf_recv.c
+++ b/code/core/rbuf_recv.c
@@ -149,22 +149,20 @@ static int ack_send(ECPConnection *conn) {
static int ack_shift(ECPRBRecv *buf) {
int do_ack = 0;
+ int in_rbuf = 0;
int idx;
int i;
if ((buf->flags & ECP_RBUF_FLAG_RELIABLE) && ((buf->ack_map & ACK_MASK_FIRST) == 0)) return 0;
- idx = ecp_rbuf_msg_idx(&buf->rbuf, buf->seq_ack);
- if (idx < 0) return idx;
-
while (ECP_SEQ_LT(buf->seq_ack, buf->rbuf.seq_max)) {
- idx = ECP_RBUF_IDX_MASK(idx + 1, buf->rbuf.msg_size);
buf->seq_ack++;
+ in_rbuf = ECP_SEQ_LT(buf->seq_ack, buf->rbuf.seq_start) ? 1 : buf->rbuf.msg[ECP_RBUF_IDX_MASK(buf->rbuf.msg_start + buf->seq_ack - buf->rbuf.seq_start, buf->rbuf.msg_size)].flags & ECP_RBUF_FLAG_IN_RBUF;
- if ((buf->rbuf.msg[idx].flags & ECP_RBUF_FLAG_IN_RBUF) && (buf->ack_map == ECP_ACK_FULL)) continue;
+ if (in_rbuf && (buf->ack_map == ECP_ACK_FULL)) continue;
buf->ack_map = buf->ack_map << 1;
- if (buf->rbuf.msg[idx].flags & ECP_RBUF_FLAG_IN_RBUF) {
+ if (in_rbuf & ECP_RBUF_FLAG_IN_RBUF) {
buf->ack_map |= 1;
} else if (!do_ack && ECP_SEQ_LTE(buf->seq_ack, buf->rbuf.seq_max - 2 * buf->hole_max)) {
do_ack = 1;