WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-api

[Xen-API] [PATCH 1 of 5] CA-42914: Catch other exceptions when reading c

To: xen-api@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-API] [PATCH 1 of 5] CA-42914: Catch other exceptions when reading commands from client in block_device_io
From: Jonathan Davies <jonathan.davies@xxxxxxxxxx>
Date: Tue, 26 Oct 2010 14:44:58 +0100
Delivery-date: Tue, 26 Oct 2010 06:45:40 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1288100697@dusk>
List-help: <mailto:xen-api-request@lists.xensource.com?subject=help>
List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>
List-post: <mailto:xen-api@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-api-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Jonathan Davies <jonathan.davies@xxxxxxxxxx>
# Date 1288100550 -3600
# Node ID 0d8152a7feb0bf514929c4f1757fdf9c05143f25
# Parent  90e9ddf70ae2ad7b8fffda73145ad1982c7f25cf
CA-42914: Catch other exceptions when reading commands from client in 
block_device_io

Previously, we only caught End_of_file which Unixext.really_read throws when 
the client sends EOF. Other exceptions dribbled through to the deeper exception 
handler, which was supposed to be reserved exclusively for problems opening the 
block device.

Now, we also catch other exceptions in the same place as the End_of_file 
exception is handled.

Signed-off-by: Jonathan Davies <jonathan.davies@xxxxxxxxxx>

diff -r 90e9ddf70ae2 -r 0d8152a7feb0 ocaml/database/block_device_io.ml
--- a/ocaml/database/block_device_io.ml Tue Oct 26 14:42:29 2010 +0100
+++ b/ocaml/database/block_device_io.ml Tue Oct 26 14:42:30 2010 +0100
@@ -784,15 +784,21 @@
                 let target_response_time = Unix.gettimeofday() +. 
Xapi_globs.redo_log_max_block_time in
                 (* Note: none of the action functions throw any exceptions; 
they report errors directly to the client. *)
                 let action_fn = match str with
-                | "writedelta" -> action_writedelta
-                | "writedb___" -> action_writedb
-                | "read______" -> action_read
-                | "empty_____" -> action_empty
-                | _ -> (fun _ _ _ _ -> send_failure client (str^"|nack") 
("Unknown command "^str)) in
+                  | "writedelta" -> action_writedelta
+                  | "writedb___" -> action_writedb
+                  | "read______" -> action_read
+                  | "empty_____" -> action_empty
+                  | _ -> (fun _ _ _ _ -> send_failure client (str^"|nack") 
("Unknown command "^str))
+                in
                 action_fn block_dev_fd client !datasock target_response_time
-              with End_of_file -> stop := true
+              with (* this must be an exception in Unixext.really_read because 
action_fn doesn't throw exceptions *)
+              | End_of_file ->
+                  R.info "The client sent EOF";
+                  stop := true
+              | e ->
+                  R.info "Unexpected error when trying to read from client: 
%s. Closing connection." (Printexc.to_string e);
+                  stop := true
             done;
-            (* The client sent EOF *)
             R.debug "Stopping.";
             ignore_exn (fun () -> Unix.close client)
           )
@@ -802,11 +808,11 @@
           )
       with (* problems opening block device *)
       | Unix.Unix_error(a,b,c) ->
-        R.error "Unix error on %s (%s) [%s]" b (Unix.error_message a) c;
+        R.error "Unix error when opening block device: %s (%s) [%s]" b 
(Unix.error_message a) c;
         ignore_exn (fun () -> send_failure client connect_failure_mesg 
(Printf.sprintf "Unix error on %s (%s) [%s]" b (Unix.error_message a) c));
         ignore_exn (fun () -> Unix.close client)
       | e ->
-        R.error "Received exception: %s" (Printexc.to_string e);
+        R.error "Unexpected exception when opening block device: %s" 
(Printexc.to_string e);
         ignore_exn (fun () -> send_failure client connect_failure_mesg 
(Printexc.to_string e));
         ignore_exn (fun () -> Unix.close client)
     done

Attachment: xen-api.hg-5.patch
Description: Text Data

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api