aboutsummaryrefslogtreecommitdiffstats
path: root/tools/ocaml/libs
diff options
context:
space:
mode:
authorIan Campbell <ian.campbell@citrix.com>2011-12-15 16:50:36 +0000
committerIan Campbell <ian.campbell@citrix.com>2011-12-15 16:50:36 +0000
commit25c4397fb24d0253dccfdb8bbe12cf3fd0504103 (patch)
tree3129933424d631b4afe1267cbc2a6be05e0119f2 /tools/ocaml/libs
parentbe1a130a99285a5ae6937f890ba31be1f7a5a9dc (diff)
downloadxen-25c4397fb24d0253dccfdb8bbe12cf3fd0504103.tar.gz
xen-25c4397fb24d0253dccfdb8bbe12cf3fd0504103.tar.bz2
xen-25c4397fb24d0253dccfdb8bbe12cf3fd0504103.zip
oxenstored: handle unknown operations by returning an error to the client
Previous an unknown operation would be decoded as a Not_found exception which would bubble all the way up to the try ... with surrounding the call to main_loop where it would be logged and ignored. This would leave the guest hanging waiting for a response to the invalid request. Instead introduce a specific "Invalid" operation. Higher level functionality, such as Process.process_packet, already handles operations which are not understood with an error reply due to the final wildcard entry in Process.function_of_type but explicitly handle Invalid this way to make it clear what is going on. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
Diffstat (limited to 'tools/ocaml/libs')
-rw-r--r--tools/ocaml/libs/xb/op.ml6
-rw-r--r--tools/ocaml/libs/xb/xb.mli1
2 files changed, 4 insertions, 3 deletions
diff --git a/tools/ocaml/libs/xb/op.ml b/tools/ocaml/libs/xb/op.ml
index 1ce72da348..0ee866676f 100644
--- a/tools/ocaml/libs/xb/op.ml
+++ b/tools/ocaml/libs/xb/op.ml
@@ -19,8 +19,7 @@ type operation = Debug | Directory | Read | Getperms |
Transaction_end | Introduce | Release |
Getdomainpath | Write | Mkdir | Rm |
Setperms | Watchevent | Error | Isintroduced |
- Resume | Set_target
- | Restrict
+ Resume | Set_target | Restrict | Invalid
let operation_c_mapping =
[| Debug; Directory; Read; Getperms;
@@ -41,7 +40,7 @@ let array_search el a =
let of_cval i =
if i >= 0 && i < size
then operation_c_mapping.(i)
- else raise Not_found
+ else Invalid
let to_cval op =
array_search op operation_c_mapping
@@ -69,3 +68,4 @@ let to_string ty =
| Resume -> "RESUME"
| Set_target -> "SET_TARGET"
| Restrict -> "RESTRICT"
+ | Invalid -> "INVALID"
diff --git a/tools/ocaml/libs/xb/xb.mli b/tools/ocaml/libs/xb/xb.mli
index 1dde52db1e..58234aefed 100644
--- a/tools/ocaml/libs/xb/xb.mli
+++ b/tools/ocaml/libs/xb/xb.mli
@@ -23,6 +23,7 @@ module Op :
| Resume
| Set_target
| Restrict
+ | Invalid (* Not a valid wire operation *)
val operation_c_mapping : operation array
val size : int
val array_search : 'a -> 'a array -> int