Skip to content

Commit 393a5ef

Browse files
committed
Fix logging as tests are failing
1 parent 3d9ef87 commit 393a5ef

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/build_log.ml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ type t = {
1010
| `Finished
1111
];
1212
mutable len : int;
13+
path : string option;
1314
}
1415

1516
let with_dup fd fn =
@@ -74,13 +75,19 @@ let create path =
7475
{
7576
state = `Open (fd, cond);
7677
len = 0;
78+
path = Some path;
7779
}
7880

7981
let finish t =
8082
match t.state with
8183
| `Finished -> Lwt.return_unit
8284
| `Open (fd, cond) ->
83-
t.state <- `Finished;
85+
(* Close the fd (needed on Windows before the directory can be renamed)
86+
but transition to Readonly so late-joining tailers can still read
87+
the log file by path. *)
88+
(match t.path with
89+
| Some path -> t.state <- `Readonly path
90+
| None -> t.state <- `Finished);
8491
Lwt_unix.close fd >|= fun () ->
8592
Lwt_condition.broadcast cond ()
8693
| `Readonly _ ->
@@ -105,6 +112,7 @@ let of_saved path =
105112
{
106113
state = `Readonly path;
107114
len = stat.st_size;
115+
path = Some path;
108116
}
109117

110118
let printf t fmt =
@@ -113,6 +121,7 @@ let printf t fmt =
113121
let empty = {
114122
state = `Empty;
115123
len = 0;
124+
path = None;
116125
}
117126

118127
let copy ~src ~dst =

0 commit comments

Comments
 (0)