]> xenbits.xen.org Git - xenclient/toolstack.git/commitdiff
Prevent xenstored death when out-of-disk space
authorTomasz Wroblewski <tomasz.wroblewski@citrix.com>
Mon, 30 Nov 2009 18:08:15 +0000 (18:08 +0000)
committerTomasz Wroblewski <tomasz.wroblewski@citrix.com>
Mon, 30 Nov 2009 18:08:15 +0000 (18:08 +0000)
libs/log/log.ml
xenstored/logging.ml
xenstored/xenstored.ml

index 23ea6d7f0f62f64da4ad51067d5a1a9a30318fdf..4f42759deba7cbc4cd2c003fad55a038abe3d3c3 100644 (file)
@@ -225,7 +225,9 @@ let output t ?(key="") ?(extra="") priority (message: string) =
        (* log-rotate at appropriate times *)
        let write_to_stream stream =
          let string = (construct_string true) in
-         fprintf stream "%s\n%!" string;
+         try
+           fprintf stream "%s\n%!" string
+         with _ -> () (* Trap exception when we fail to write log *)
         in
 
        if String.length message > 0 then
@@ -249,7 +251,7 @@ let log t level (fmt: ('a, unit, string, unit) format4): 'a =
        (* ksprintf is the preferred name for kprintf, but the former
         * is not available in OCaml 3.08.3 *)
        Printf.kprintf (if b then output t level else (fun _ -> ())) fmt
-
+           
 let debug t (fmt: ('a , unit, string, unit) format4) = log t Debug fmt
 let info t (fmt: ('a , unit, string, unit) format4) = log t Info fmt
 let warn t (fmt: ('a , unit, string, unit) format4) = log t Warn fmt
index 19fbfe4e25e29728d2bc9bb946f6ecbcd900c47c..639ac2a7d189fd119d56f7c463cd74d803792758 100644 (file)
@@ -193,7 +193,9 @@ let init aal save_to_disk =
        access := Some (make save_to_disk)
 
 let write_access_log ~con ~tid ?data access_type = 
-       Pervasiveext.maybe (fun a -> a.write access_type ~con ~tid ?data) !access
+        try
+         Pervasiveext.maybe (fun a -> a.write access_type ~con ~tid ?data) !access
+       with _ -> ()
 
 let new_connection = write_access_log Newconn
 let end_connection = write_access_log Endconn
index 1fc43cf1fead2b2d0559efa651bb04c31840c914..9465d7721307c424f3959ef8a2d01db587282db7 100644 (file)
@@ -226,7 +226,9 @@ let _ =
 
        let cf = do_argv in
        let pidfile = parse_config (config_filename cf) in
-       Unixext.mkdir_rec (Filename.dirname pidfile) 0o755;
+       (try 
+         Unixext.mkdir_rec (Filename.dirname pidfile) 0o755
+       with _ -> ());
 
        let rw_sock, ro_sock =
                if cf.disable_socket then
@@ -239,7 +241,9 @@ let _ =
        if cf.daemonize then
                Unixext.daemonize ();
 
-       Unixext.pidfile_write pidfile;
+       (try
+         Unixext.pidfile_write pidfile
+       with _ -> ());
 
        info "Xen Storage Daemon, version %d.%d"
             Define.xenstored_major Define.xenstored_minor;