X-Git-Url: http://matita.cs.unibo.it/gitweb/?p=helm.git;a=blobdiff_plain;f=helm%2Fhttp_getter%2Fhttp_getter_map.ml;h=07c2c10b4a0db1c667bfa4eef2edabb985cd3ce3;hp=9ee87618104003943e0f49484c7e98be736a1a0a;hb=34ce9fa57cd6c138454a69b1a0e6675118e3abc7;hpb=eebee42bc011c09766d09aa18942f95671531a9e diff --git a/helm/http_getter/http_getter_map.ml b/helm/http_getter/http_getter_map.ml index 9ee876181..07c2c10b4 100644 --- a/helm/http_getter/http_getter_map.ml +++ b/helm/http_getter/http_getter_map.ml @@ -24,16 +24,22 @@ * http://cs.unibo.it/helm/. *) +let debug = true;; +let debug_print s = if debug then prerr_endline s;; + exception Key_already_in of string;; exception Key_not_found of string;; class map dbname = let perm = 420 in (* permission 644 in decimal notation *) - let db = Dbm.opendbm dbname [ Dbm.Dbm_rdwr; Dbm.Dbm_create ] perm in + let open_dbm () = Dbm.opendbm dbname [ Dbm.Dbm_rdwr; Dbm.Dbm_create ] perm in + object (self) inherit ThreadSafe.threadSafe + val mutable db = open_dbm () + initializer Gc.finalise Dbm.close db (* close db on GC *) method add key value = @@ -62,7 +68,10 @@ class map dbname = method clear = self#doWriter (lazy ( - Dbm.iter (fun k _ -> Dbm.remove db k) db + Dbm.close db; + Sys.remove (dbname ^ ".dir"); + Sys.remove (dbname ^ ".pag"); + db <- open_dbm () )) end