Skip to content

Commit

Permalink
tcp: Remove tcb from tcbs when connection is closed
Browse files Browse the repository at this point in the history
Currently tcb are inserted but never removed from tcbs.

This patch also removes an unnecessary <ACK> packet (packet #5 below) to
the client.

1) client: <FIN>
2) server: <ACK>
3) server: <FIN>
4) client: <ACK>
5) server: <ACK>
  • Loading branch information
asias authored and avikivity committed Oct 22, 2014
1 parent 05effc0 commit aa06198
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions net/tcp.hh
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,11 @@ private:
future<> send(packet p);
packet read();
void close();
void remove_from_tcbs() {
auto id = connid{_local_ip, _foreign_ip, _local_port, _foreign_port};
_tcp._tcbs.erase(id);
}
bool both_closed() { return _foreign_fin_received && _local_fin_acked; }
private:
void respond_with_reset(tcp_hdr* th);
void merge_out_of_order();
Expand Down Expand Up @@ -547,6 +552,11 @@ void tcp<InetTraits>::tcb::input(tcp_hdr* th, packet p) {
if (_local_fin_sent && th->ack == _snd.next + 1) {
_local_fin_acked = true;
_snd.next += 1;
if (both_closed()) {
clear_delayed_ack();
remove_from_tcbs();
return;
}
}
}

Expand Down

0 comments on commit aa06198

Please sign in to comment.