Skip to content

Commit 1bd6270

Browse files
committedJul 18, 2022
extract timewait transition to a new function
1 parent cd90787 commit 1bd6270

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed
 

‎src/tcp/state.ml

+6-7
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ module Make(Time:Mirage_time.S) = struct
119119
t.on_close ();
120120
Lwt.return_unit
121121

122+
let transition_to_timewait t =
123+
Lwt.async (fun () -> timewait t time_wait_time);
124+
Time_wait
125+
122126
let tick t (i:action) =
123127
let diffone x y = Sequence.succ y = x in
124128
let tstr s (i:action) =
@@ -148,15 +152,10 @@ module Make(Time:Mirage_time.S) = struct
148152
| Fin_wait_1 _, Recv_rst -> t.on_close (); Reset
149153
| Fin_wait_2 i, Recv_ack _ -> Fin_wait_2 (i + 1)
150154
| Fin_wait_2 _, Recv_rst -> t.on_close (); Reset
151-
| Fin_wait_2 _, Recv_fin ->
152-
Lwt.async (fun () -> timewait t time_wait_time);
153-
Time_wait
155+
| Fin_wait_2 _, Recv_fin -> transition_to_timewait t
154156
| Closing a, Recv_ack b ->
155157
if diffone b a then
156-
begin
157-
Lwt.async (fun () -> timewait t time_wait_time);
158-
Time_wait
159-
end
158+
transition_to_timewait t
160159
else Closing a
161160
| Closing _, Timeout -> t.on_close (); Closed
162161
| Closing _, Recv_rst -> t.on_close (); Reset

0 commit comments

Comments
 (0)
Please sign in to comment.