Skip to content

Commit d0b9e2a

Browse files
author
Romain Slootmaekers
committed
don't die, but call all handlers when inner loop fails
1 parent 829090e commit d0b9e2a

File tree

4 files changed

+21
-10
lines changed

4 files changed

+21
-10
lines changed

META

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- conf -*-
22

33
description = "Kinetic client"
4-
version = "0.0.3"
4+
version = "0.0.4"
55
exists_if = "kinetic.cmx,kinetic.cmi,kinetic.mli"
66
requires = "threads lwt lwt.unix cryptokit"
77
archive(byte) = "kinetic.client.cma"

README.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ This is an OCaml client for [Seagate's Kinetic drives](https://developers.seagat
44
Currently, it uses protocol version 3.0.6.
55
This is corresponds with version 0.8.0.3 of the Java Simulator.
66

7-
Todo:
8-
- [X] support 3.X protocol
9-
- [ ] use 4.0.2 Bytes iso strings for buffers (depends on piqi)
10-
- [X] opam installable
11-
- [ ] publish 0.0.3 on opam repo
127

138
Installation
149
============

src/kinetic.ml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,8 @@ struct
333333

334334
let remove t h = Hashtbl.remove t h
335335

336-
let make session (ic,oc) batch_id =
336+
let make session conn batch_id =
337+
let ic,oc = conn in
337338
let handlers = Hashtbl.create 5 in
338339
let mvar = Lwt_mvar.create_empty () in
339340
let rec loop (go:bool ref) (ic:Lwt_io.input_channel) =
@@ -379,9 +380,22 @@ struct
379380
end
380381
in
381382
let go = ref true in
382-
let t = loop go ic in
383+
let t =
384+
Lwt.catch
385+
(fun () ->loop go ic )
386+
(fun exn ->
387+
Lwt_log.debug_f ~exn ~section "batch loop for %li failed" batch_id
388+
>>= fun ()->
389+
let rci = status_code2i `internal_error in
390+
let rc_bad = Nok (rci, Printexc.to_string exn) in
391+
Hashtbl.iter (fun k h ->
392+
Lwt.ignore_result (h rc_bad);
393+
) handlers;
394+
Lwt.return ()
395+
)
396+
in
383397
let () = Lwt.ignore_result t in
384-
{ mvar ; handlers ; conn = (ic,oc) ; batch_id; go = go; session}
398+
{ mvar ; handlers ; conn; batch_id; go = go; session}
385399

386400
let add_handler t typ h =
387401
let typs = message_type2s typ in

src/kinetic.mli

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ module Kinetic : sig
8888

8989
(**
9090
Batches are atomic multi-updates.
91-
(while you're doing a batch, you're not supposed to use the connection )
91+
Remark:
92+
- while you're doing a batch, you're not supposed to use the connection
93+
- handlers should not raise exceptions as these have no where to go.
9294
*)
9395
val start_batch_operation :
9496
?handler:handler ->

0 commit comments

Comments
 (0)