File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ type t = {
1010 | `Finished
1111 ];
1212 mutable len : int ;
13+ path : string option ;
1314}
1415
1516let 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
7981let 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
110118let printf t fmt =
@@ -113,6 +121,7 @@ let printf t fmt =
113121let empty = {
114122 state = `Empty ;
115123 len = 0 ;
124+ path = None ;
116125}
117126
118127let copy ~src ~dst =
You can’t perform that action at this time.
0 commit comments