File tree Expand file tree Collapse file tree 2 files changed +13
-8
lines changed Expand file tree Collapse file tree 2 files changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -543,7 +543,7 @@ let monitor_write_loop writers =
543543 ) ;
544544 Thread. delay ! Rrdd_shared. timeslice
545545 with e ->
546- debug
546+ warn
547547 " Monitor/write thread caught an exception. Pausing for 10s, \
548548 then restarting: %s"
549549 (Printexc. to_string e) ;
Original file line number Diff line number Diff line change 1414
1515type local_id = {path : string ; shared_page_count : int }
1616
17+ let finally f finally = Fun. protect ~finally f
18+
1719module File = struct
1820 let page_size = 4096
1921
@@ -29,14 +31,17 @@ module File = struct
2931 let init {path; shared_page_count} =
3032 let size = shared_page_count * page_size in
3133 let fd = Unix. openfile path [Unix. O_RDWR ; Unix. O_CREAT ] 0o600 in
32- let mapping =
33- Bigarray. (
34- array1_of_genarray @@ Unix. map_file fd char c_layout true [|size|]
34+ finally
35+ (fun () ->
36+ let mapping =
37+ Bigarray. (
38+ array1_of_genarray @@ Unix. map_file fd char c_layout true [|size|]
39+ )
40+ in
41+ let cstruct = Cstruct. of_bigarray mapping in
42+ (path, cstruct)
3543 )
36- in
37- Unix. close fd ;
38- let cstruct = Cstruct. of_bigarray mapping in
39- (path, cstruct)
44+ (fun () -> Unix. close fd)
4045
4146 let cleanup _ path _ = Unix. unlink path
4247
You can’t perform that action at this time.
0 commit comments