From 4e5937b99754e7782825cd0cc05984d9b90302a8 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> Date: Sun, 5 Aug 2018 19:40:59 +0900 Subject: [PATCH] Rename ngtcp2_acktr.ent to ngtcp2_acktr.ents --- lib/ngtcp2_acktr.c | 28 ++++++++++++++-------------- lib/ngtcp2_acktr.h | 7 +++---- tests/ngtcp2_acktr_test.c | 14 +++++++------- tests/ngtcp2_conn_test.c | 6 +++--- 4 files changed, 27 insertions(+), 28 deletions(-) diff --git a/lib/ngtcp2_acktr.c b/lib/ngtcp2_acktr.c index e4c658a2..4ab9393a 100644 --- a/lib/ngtcp2_acktr.c +++ b/lib/ngtcp2_acktr.c @@ -58,7 +58,7 @@ int ngtcp2_acktr_init(ngtcp2_acktr *acktr, int delayed_ack, ngtcp2_log *log, return rv; } - rv = ngtcp2_ksl_init(&acktr->ent, greater, -1, mem); + rv = ngtcp2_ksl_init(&acktr->ents, greater, -1, mem); if (rv != 0) { ngtcp2_ringbuf_free(&acktr->acks); return rv; @@ -82,11 +82,11 @@ void ngtcp2_acktr_free(ngtcp2_acktr *acktr) { return; } - for (it = ngtcp2_ksl_begin(&acktr->ent); !ngtcp2_ksl_it_end(&it); + for (it = ngtcp2_ksl_begin(&acktr->ents); !ngtcp2_ksl_it_end(&it); ngtcp2_ksl_it_next(&it)) { ngtcp2_acktr_entry_del(ngtcp2_ksl_it_get(&it), acktr->mem); } - ngtcp2_ksl_free(&acktr->ent); + ngtcp2_ksl_free(&acktr->ents); for (i = 0; i < acktr->acks.len; ++i) { ack_ent = ngtcp2_ringbuf_get(&acktr->acks, i); @@ -101,14 +101,14 @@ int ngtcp2_acktr_add(ngtcp2_acktr *acktr, ngtcp2_acktr_entry *ent, ngtcp2_acktr_entry *delent; int rv; - it = ngtcp2_ksl_lower_bound(&acktr->ent, (int64_t)ent->pkt_num); + it = ngtcp2_ksl_lower_bound(&acktr->ents, (int64_t)ent->pkt_num); if (!ngtcp2_ksl_it_end(&it) && ngtcp2_ksl_it_key(&it) == (int64_t)ent->pkt_num) { /* TODO What to do if we receive duplicated packet number? */ return NGTCP2_ERR_INVALID_ARGUMENT; } - rv = ngtcp2_ksl_insert(&acktr->ent, NULL, (int64_t)ent->pkt_num, ent); + rv = ngtcp2_ksl_insert(&acktr->ents, NULL, (int64_t)ent->pkt_num, ent); if (rv != 0) { return rv; } @@ -120,11 +120,11 @@ int ngtcp2_acktr_add(ngtcp2_acktr *acktr, ngtcp2_acktr_entry *ent, } } - if (ngtcp2_ksl_len(&acktr->ent) > NGTCP2_ACKTR_MAX_ENT) { - it = ngtcp2_ksl_end(&acktr->ent); + if (ngtcp2_ksl_len(&acktr->ents) > NGTCP2_ACKTR_MAX_ENT) { + it = ngtcp2_ksl_end(&acktr->ents); ngtcp2_ksl_it_prev(&it); delent = ngtcp2_ksl_it_get(&it); - ngtcp2_ksl_remove(&acktr->ent, NULL, (int64_t)delent->pkt_num); + ngtcp2_ksl_remove(&acktr->ents, NULL, (int64_t)delent->pkt_num); ngtcp2_acktr_entry_del(delent, acktr->mem); } @@ -135,12 +135,12 @@ int ngtcp2_acktr_forget(ngtcp2_acktr *acktr, ngtcp2_acktr_entry *ent) { ngtcp2_ksl_it it; int rv; - it = ngtcp2_ksl_lower_bound(&acktr->ent, (int64_t)ent->pkt_num); + it = ngtcp2_ksl_lower_bound(&acktr->ents, (int64_t)ent->pkt_num); assert(ngtcp2_ksl_it_key(&it) == (int64_t)ent->pkt_num); for (; !ngtcp2_ksl_it_end(&it);) { ent = ngtcp2_ksl_it_get(&it); - rv = ngtcp2_ksl_remove(&acktr->ent, &it, (int64_t)ent->pkt_num); + rv = ngtcp2_ksl_remove(&acktr->ents, &it, (int64_t)ent->pkt_num); if (rv != 0) { return rv; } @@ -151,7 +151,7 @@ int ngtcp2_acktr_forget(ngtcp2_acktr *acktr, ngtcp2_acktr_entry *ent) { } ngtcp2_ksl_it ngtcp2_acktr_get(ngtcp2_acktr *acktr) { - return ngtcp2_ksl_begin(&acktr->ent); + return ngtcp2_ksl_begin(&acktr->ents); } ngtcp2_acktr_ack_entry *ngtcp2_acktr_add_ack(ngtcp2_acktr *acktr, @@ -188,7 +188,7 @@ static int acktr_remove(ngtcp2_acktr *acktr, ngtcp2_ksl_it *it, ngtcp2_acktr_entry *ent) { int rv; - rv = ngtcp2_ksl_remove(&acktr->ent, it, (int64_t)ent->pkt_num); + rv = ngtcp2_ksl_remove(&acktr->ents, it, (int64_t)ent->pkt_num); if (rv != 0) { return rv; } @@ -214,7 +214,7 @@ static int acktr_on_ack(ngtcp2_acktr *acktr, ngtcp2_ringbuf *rb, min_ack = largest_ack - fr->first_ack_blklen; /* Assume that ngtcp2_pkt_validate_ack(fr) returns 0 */ - it = ngtcp2_ksl_lower_bound(&acktr->ent, (int64_t)largest_ack); + it = ngtcp2_ksl_lower_bound(&acktr->ents, (int64_t)largest_ack); if (ngtcp2_ksl_it_end(&it)) { goto fin; } @@ -234,7 +234,7 @@ static int acktr_on_ack(ngtcp2_acktr *acktr, ngtcp2_ringbuf *rb, largest_ack = min_ack - fr->blks[i].gap - 2; min_ack = largest_ack - fr->blks[i].blklen; - it = ngtcp2_ksl_lower_bound(&acktr->ent, (int64_t)largest_ack); + it = ngtcp2_ksl_lower_bound(&acktr->ents, (int64_t)largest_ack); if (ngtcp2_ksl_it_end(&it)) { break; } diff --git a/lib/ngtcp2_acktr.h b/lib/ngtcp2_acktr.h index b2d41abd..5caedf5f 100644 --- a/lib/ngtcp2_acktr.h +++ b/lib/ngtcp2_acktr.h @@ -105,9 +105,9 @@ typedef enum { */ typedef struct { ngtcp2_ringbuf acks; - /* ent includes ngtcp2_acktr_entry sorted by decreasing order of + /* ents includes ngtcp2_acktr_entry sorted by decreasing order of packet number. */ - ngtcp2_ksl ent; + ngtcp2_ksl ents; ngtcp2_log *log; ngtcp2_mem *mem; /* flags is bitwise OR of zero, or more of ngtcp2_ack_flag. */ @@ -132,8 +132,7 @@ int ngtcp2_acktr_init(ngtcp2_acktr *acktr, int delayed_ack, ngtcp2_log *log, /* * ngtcp2_acktr_free frees resources allocated for |acktr|. It frees - * any ngtcp2_acktr_entry directly or indirectly pointed by - * acktr->ent. + * any ngtcp2_acktr_entry added to |acktr|. */ void ngtcp2_acktr_free(ngtcp2_acktr *acktr); diff --git a/tests/ngtcp2_acktr_test.c b/tests/ngtcp2_acktr_test.c index c42d43fd..19a78a7f 100644 --- a/tests/ngtcp2_acktr_test.c +++ b/tests/ngtcp2_acktr_test.c @@ -65,7 +65,7 @@ void test_ngtcp2_acktr_add(void) { for (i = 0; i < arraylen(ents); ++i) { it = ngtcp2_acktr_get(&acktr); ent = ngtcp2_ksl_it_get(&it); - ngtcp2_ksl_remove(&acktr.ent, NULL, (int64_t)ent->pkt_num); + ngtcp2_ksl_remove(&acktr.ents, NULL, (int64_t)ent->pkt_num); ngtcp2_acktr_entry_del(ent, mem); it = ngtcp2_acktr_get(&acktr); @@ -113,7 +113,7 @@ void test_ngtcp2_acktr_eviction(void) { ngtcp2_acktr_add(&acktr, ent, 1, 999 + i); } - CU_ASSERT(NGTCP2_ACKTR_MAX_ENT == ngtcp2_ksl_len(&acktr.ent)); + CU_ASSERT(NGTCP2_ACKTR_MAX_ENT == ngtcp2_ksl_len(&acktr.ents)); for (i = 0, it = ngtcp2_acktr_get(&acktr); !ngtcp2_ksl_it_end(&it); ++i, ngtcp2_ksl_it_next(&it)) { @@ -132,7 +132,7 @@ void test_ngtcp2_acktr_eviction(void) { ngtcp2_acktr_add(&acktr, ent, 1, 999 + i); } - CU_ASSERT(NGTCP2_ACKTR_MAX_ENT == ngtcp2_ksl_len(&acktr.ent)); + CU_ASSERT(NGTCP2_ACKTR_MAX_ENT == ngtcp2_ksl_len(&acktr.ents)); for (i = 0, it = ngtcp2_acktr_get(&acktr); !ngtcp2_ksl_it_end(&it); ++i, ngtcp2_ksl_it_next(&it)) { @@ -160,7 +160,7 @@ void test_ngtcp2_acktr_forget(void) { ngtcp2_acktr_add(&acktr, ent, 1, 999 + i); } - CU_ASSERT(7 == ngtcp2_ksl_len(&acktr.ent)); + CU_ASSERT(7 == ngtcp2_ksl_len(&acktr.ents)); it = ngtcp2_acktr_get(&acktr); ngtcp2_ksl_it_next(&it); @@ -169,7 +169,7 @@ void test_ngtcp2_acktr_forget(void) { ent = ngtcp2_ksl_it_get(&it); ngtcp2_acktr_forget(&acktr, ent); - CU_ASSERT(3 == ngtcp2_ksl_len(&acktr.ent)); + CU_ASSERT(3 == ngtcp2_ksl_len(&acktr.ents)); it = ngtcp2_acktr_get(&acktr); ent = ngtcp2_ksl_it_get(&it); @@ -191,7 +191,7 @@ void test_ngtcp2_acktr_forget(void) { ngtcp2_acktr_forget(&acktr, ent); - CU_ASSERT(0 == ngtcp2_ksl_len(&acktr.ent)); + CU_ASSERT(0 == ngtcp2_ksl_len(&acktr.ents)); ngtcp2_acktr_free(&acktr); } @@ -245,7 +245,7 @@ void test_ngtcp2_acktr_recv_ack(void) { ngtcp2_acktr_recv_ack(&acktr, &ackfr, NULL, 1000000009); CU_ASSERT(0 == ngtcp2_ringbuf_len(&acktr.acks)); - CU_ASSERT(5 == ngtcp2_ksl_len(&acktr.ent)); + CU_ASSERT(5 == ngtcp2_ksl_len(&acktr.ents)); it = ngtcp2_acktr_get(&acktr); ent = ngtcp2_ksl_it_get(&it); diff --git a/tests/ngtcp2_conn_test.c b/tests/ngtcp2_conn_test.c index 2843b600..0c3e6940 100644 --- a/tests/ngtcp2_conn_test.c +++ b/tests/ngtcp2_conn_test.c @@ -1801,7 +1801,7 @@ void test_ngtcp2_conn_recv_delayed_handshake_pkt(void) { rv = ngtcp2_conn_recv(conn, buf, pktlen, 1); CU_ASSERT(0 == rv); - CU_ASSERT(1 == ngtcp2_ksl_len(&conn->hs_pktns.acktr.ent)); + CU_ASSERT(1 == ngtcp2_ksl_len(&conn->hs_pktns.acktr.ents)); CU_ASSERT(conn->hs_pktns.acktr.flags & NGTCP2_ACKTR_FLAG_ACTIVE_ACK); ngtcp2_conn_del(conn); @@ -1845,7 +1845,7 @@ void test_ngtcp2_conn_recv_delayed_handshake_pkt(void) { rv = ngtcp2_conn_recv(conn, buf, pktlen, 1); CU_ASSERT(0 == rv); - CU_ASSERT(1 == ngtcp2_ksl_len(&conn->hs_pktns.acktr.ent)); + CU_ASSERT(1 == ngtcp2_ksl_len(&conn->hs_pktns.acktr.ents)); CU_ASSERT(!conn->hs_pktns.acktr.flags); ngtcp2_conn_del(conn); @@ -2978,7 +2978,7 @@ void test_ngtcp2_conn_pkt_payloadlen(void) { spktlen = ngtcp2_conn_handshake(conn, buf, sizeof(buf), buf, pktlen, ++t); CU_ASSERT(spktlen == 0); - CU_ASSERT(0 == ngtcp2_ksl_len(&conn->in_pktns.acktr.ent)); + CU_ASSERT(0 == ngtcp2_ksl_len(&conn->in_pktns.acktr.ents)); ngtcp2_conn_del(conn); } -- GitLab