Quantcast

[xen stable-4.4] oxenstored: refactor request processing

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[xen stable-4.4] oxenstored: refactor request processing

patchbot
commit 19b1599ae3a7d391ea26699999ff4d56e5b61d00
Author:     Jonathan Davies <[hidden email]>
AuthorDate: Thu Mar 23 17:40:27 2017 +0000
Commit:     Ian Jackson <[hidden email]>
CommitDate: Wed Apr 5 15:26:37 2017 +0100

    oxenstored: refactor request processing
   
    Encapsulate the request in a record that is passed from do_input to
    process_packet and input_handle_error.
   
    This will be helpful when keeping track of the requests made as part of a
    transaction.
   
    Reported-by: Juergen Gross <[hidden email]>
    Signed-off-by: Jonathan Davies <[hidden email]>
    Reviewed-by: Andrew Cooper <[hidden email]>
    Reviewed-by: Jon Ludlam <[hidden email]>
    Reviewed-by: Euan Harris <[hidden email]>
    Acked-by: David Scott <[hidden email]>
---
 tools/ocaml/xenstored/packet.ml  |  7 +++++++
 tools/ocaml/xenstored/process.ml | 15 ++++++++++-----
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/tools/ocaml/xenstored/packet.ml b/tools/ocaml/xenstored/packet.ml
index c8ecfe5..22cae1d 100644
--- a/tools/ocaml/xenstored/packet.ml
+++ b/tools/ocaml/xenstored/packet.ml
@@ -1,3 +1,10 @@
+type request = {
+ tid: int;
+ rid: int;
+ ty: Xenbus.Xb.Op.operation;
+ data: string;
+}
+
 type response =
  | Ack of (unit -> unit)  (* function is the action to execute after sending the ack *)
  | Reply of string
diff --git a/tools/ocaml/xenstored/process.ml b/tools/ocaml/xenstored/process.ml
index 7026727..b8bcb46 100644
--- a/tools/ocaml/xenstored/process.ml
+++ b/tools/ocaml/xenstored/process.ml
@@ -338,11 +338,11 @@ let function_of_type ty =
  | Xenbus.Xb.Op.Invalid           -> reply_ack do_error
  | _                              -> reply_ack do_error
 
-let input_handle_error ~cons ~doms ~fct ~ty ~con ~t ~rid ~data =
+let input_handle_error ~cons ~doms ~fct ~con ~t ~req =
  let reply_error e =
  Packet.Error e in
  try
- fct con t doms cons data
+ fct con t doms cons req.Packet.data
  with
  | Define.Invalid_path          -> reply_error "EINVAL"
  | Define.Already_exist         -> reply_error "EEXIST"
@@ -364,7 +364,10 @@ let input_handle_error ~cons ~doms ~fct ~ty ~con ~t ~rid ~data =
 (**
  * Nothrow guarantee.
  *)
-let process_packet ~store ~cons ~doms ~con ~tid ~rid ~ty ~data =
+let process_packet ~store ~cons ~doms ~con ~req =
+ let ty = req.Packet.ty in
+ let tid = req.Packet.tid in
+ let rid = req.Packet.rid in
  try
  let fct = function_of_type ty in
  let t =
@@ -373,7 +376,7 @@ let process_packet ~store ~cons ~doms ~con ~tid ~rid ~ty ~data =
  else
  Connection.get_transaction con tid
  in
- let response = input_handle_error ~cons ~doms ~fct ~ty ~con ~t ~rid ~data in
+ let response = input_handle_error ~cons ~doms ~fct ~con ~t ~req in
 
  (* Put the response on the wire *)
  send_response ty con t rid response
@@ -401,11 +404,13 @@ let do_input store cons doms con =
  if newpacket then (
  let packet = Connection.pop_in con in
  let tid, rid, ty, data = Xenbus.Xb.Packet.unpack packet in
+ let req = {Packet.tid; Packet.rid; Packet.ty; Packet.data} in
+
  (* As we don't log IO, do not call an unnecessary sanitize_data
    info "[%s] -> [%d] %s \"%s\""
          (Connection.get_domstr con) tid
          (Xenbus.Xb.Op.to_string ty) (sanitize_data data); *)
- process_packet ~store ~cons ~doms ~con ~tid ~rid ~ty ~data;
+ process_packet ~store ~cons ~doms ~con ~req;
  write_access_log ~ty ~tid ~con ~data;
  Connection.incr_ops con;
  )
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.4

_______________________________________________
Xen-changelog mailing list
[hidden email]
https://lists.xenproject.org/xen-changelog
Loading...