Skip to content

Commit

Permalink
Merge pull request #460 from dinosaure/fix-memory-leak
Browse files Browse the repository at this point in the history
Fix memory leak about RST packets
  • Loading branch information
dinosaure committed Dec 2, 2021
2 parents ccf3242 + 9eba5ad commit 9676ef3
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/tcp/segment.ml
Expand Up @@ -110,12 +110,17 @@ module Rx(Time:Mirage_time.S) = struct

let check_valid_segment q seg =
if seg.header.rst then
if Sequence.compare seg.header.sequence (Window.rx_nxt q.wnd) = 0 then
`Reset
else if Window.valid q.wnd seg.header.sequence then
`ChallengeAck
else
`Drop
begin match State.state q.state with
| State.Reset ->
`Drop
| _ ->
if Sequence.compare seg.header.sequence (Window.rx_nxt q.wnd) = 0 then
`Reset
else if Window.valid q.wnd seg.header.sequence then
`ChallengeAck
else
`Drop
end
else if seg.header.syn then
`ChallengeAck
else if Window.valid q.wnd seg.header.sequence then
Expand All @@ -131,7 +136,9 @@ module Rx(Time:Mirage_time.S) = struct
let send_challenge_ack q =
(* TODO: rfc5961 ACK Throttling *)
(* Is this the correct way trigger an ack? *)
Lwt_mvar.put q.rx_data (Some [], Some Sequence.zero)
if Lwt_mvar.is_empty q.rx_data
then Lwt_mvar.put q.rx_data (Some [], Some Sequence.zero)
else Lwt.return_unit

(* Given an input segment, the window information, and a receive
queue, update the window, extract any ready segments into the
Expand Down

0 comments on commit 9676ef3

Please sign in to comment.