File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -24,16 +24,22 @@ namespace imkcpp {
2424
2525 assert (this ->segment_tracker .should_receive (sn));
2626
27- const auto it = std::find_if (this ->rcv_buf .rbegin (), this ->rcv_buf .rend (), [sn](const Segment& seg) {
28- return sn >= seg.header .sn ;
27+ const auto rit = std::find_if (this ->rcv_buf .rbegin (), this ->rcv_buf .rend (), [sn](const Segment& seg) {
28+ return seg.header .sn < sn;
2929 });
3030
31- if (it == this ->rcv_buf .rend () || it->header .sn != sn) {
32- this ->rcv_buf .emplace (it.base (), header, data);
31+ const auto it = rit.base ();
32+
33+ if (it != this ->rcv_buf .end () && it->header .sn == sn) {
34+ return ;
3335 }
36+
37+ this ->rcv_buf .emplace (it, header, data);
3438 }
3539
36- void move_receive_buffer_to_queue (std::deque<Segment>& rcv_queue) {
40+ size_t move_receive_buffer_to_queue (std::deque<Segment>& rcv_queue) {
41+ size_t count = 0 ;
42+
3743 while (!this ->rcv_buf .empty ()) {
3844 Segment& seg = rcv_buf.front ();
3945 if (seg.header .sn != segment_tracker.get_rcv_nxt () || rcv_queue.size () >= this ->queue_limit ) {
@@ -44,7 +50,11 @@ namespace imkcpp {
4450
4551 this ->rcv_buf .pop_front ();
4652 this ->segment_tracker .increment_rcv_nxt ();
53+
54+ count++;
4755 }
56+
57+ return count;
4858 }
4959 };
5060}
You can’t perform that action at this time.
0 commit comments