File tree Expand file tree Collapse file tree 6 files changed +12
-12
lines changed Expand file tree Collapse file tree 6 files changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -21,11 +21,11 @@ let db_FLUSH_TIMER = 2.0
21
21
22
22
(* --------------------- Util functions on db datastructures *)
23
23
24
- let master_database = ref (Db_cache_types.Database. make Schema. empty)
24
+ let master_database = Atomic. make (Db_cache_types.Database. make Schema. empty)
25
25
26
- let __test_set_master_database db = master_database := db
26
+ let __test_set_master_database db = Atomic. set master_database db
27
27
28
- let make () = Db_ref. in_memory ( ref master_database)
28
+ let make () = Db_ref. in_memory master_database
29
29
30
30
(* !!! Right now this is called at cache population time. It would probably be preferable to call it on flush time instead, so we
31
31
don't waste writes storing non-persistent field values on disk.. At the moment there's not much to worry about, since there are
Original file line number Diff line number Diff line change 12
12
* GNU Lesser General Public License for more details.
13
13
*)
14
14
15
- type t = In_memory of Db_cache_types.Database .t ref ref | Remote
15
+ type t = In_memory of Db_cache_types.Database .t Atomic .t | Remote
16
16
17
17
exception Database_not_in_memory
18
18
19
- let in_memory (rf : Db_cache_types.Database.t ref ref ) = In_memory rf
19
+ let in_memory (rf : Db_cache_types.Database.t Atomic.t ) = In_memory rf
20
20
21
21
let get_database = function
22
22
| In_memory x ->
23
- ! ( ! x)
23
+ Atomic. get x
24
24
| Remote ->
25
25
raise Database_not_in_memory
26
26
27
27
let update_database t f =
28
28
match t with
29
29
| In_memory x ->
30
30
let d : Db_cache_types.Database.t = f (get_database t) in
31
- ! x := d
31
+ Atomic. set x d
32
32
| Remote ->
33
33
raise Database_not_in_memory
Original file line number Diff line number Diff line change 12
12
* GNU Lesser General Public License for more details.
13
13
*)
14
14
15
- type t = In_memory of Db_cache_types.Database .t ref ref | Remote
15
+ type t = In_memory of Db_cache_types.Database .t Atomic .t | Remote
16
16
17
17
exception Database_not_in_memory
18
18
19
- val in_memory : Db_cache_types.Database .t ref ref -> t
19
+ val in_memory : Db_cache_types.Database .t Atomic .t -> t
20
20
21
21
val get_database : t -> Db_cache_types.Database .t
22
22
Original file line number Diff line number Diff line change @@ -192,7 +192,7 @@ let restore_from_xml __context dry_run (xml_filename : string) =
192
192
(Db_xml.From. file (Datamodel_schema. of_datamodel () ) xml_filename)
193
193
in
194
194
version_check db ;
195
- let db_ref = Db_ref. in_memory (ref ( ref db) ) in
195
+ let db_ref = Db_ref. in_memory (Atomic. make db ) in
196
196
let new_context = Context. make ~database: db_ref " restore_db" in
197
197
prepare_database_for_restore ~old_context: __context ~new_context ;
198
198
(* write manifest and unmarshalled db directly to db_temporary_restore_path, so its ready for us on restart *)
Original file line number Diff line number Diff line change @@ -1569,5 +1569,5 @@ let create_from_db_file ~__context ~filename =
1569
1569
Xapi_database.Db_xml.From. file (Datamodel_schema. of_datamodel () ) filename
1570
1570
|> Xapi_database.Db_upgrade. generic_database_upgrade
1571
1571
in
1572
- let db_ref = Some (Xapi_database.Db_ref. in_memory (ref ( ref db) )) in
1572
+ let db_ref = Some (Xapi_database.Db_ref. in_memory (Atomic. make db )) in
1573
1573
create_readonly_session ~__context ~uname: " db-from-file" ~db_ref
Original file line number Diff line number Diff line change @@ -184,7 +184,7 @@ let database_ref_of_vdi ~__context ~vdi =
184
184
debug " Enabling redo_log with device reason [%s]" device ;
185
185
Redo_log. enable_block_existing log device ;
186
186
let db = Database. make (Datamodel_schema. of_datamodel () ) in
187
- let db_ref = Xapi_database.Db_ref. in_memory (ref ( ref db) ) in
187
+ let db_ref = Xapi_database.Db_ref. in_memory (Atomic. make db ) in
188
188
Redo_log_usage. read_from_redo_log log Xapi_globs. foreign_metadata_db db_ref ;
189
189
Redo_log. delete log ;
190
190
(* Upgrade database to the local schema. *)
You can’t perform that action at this time.
0 commit comments