Skip to content

Commit

Permalink
Merge pull request #48 from gaborigloi/fix_lwt_connection_leak
Browse files Browse the repository at this point in the history
Fix connection leak in Lwt client
  • Loading branch information
thomassa authored Aug 9, 2017
2 parents 0c65bbd + 3dbf24c commit d996786
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ setup.ml
*.byte
*.native
myocamlbuild.ml
_tags
*.mllib
*.mldylib
META
Expand Down
15 changes: 9 additions & 6 deletions lwt/xen_api_lwt_unix.ml
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,15 @@ let exn_to_string = function
let do_it uri string =
let uri = Uri.of_string uri in
let connection = M.make uri in
M.rpc connection string >>= fun result ->
match result with
| Ok x -> return x
| Error e ->
Printf.fprintf stderr "Caught: %s\n%!" (exn_to_string e);
fail e
Lwt.finalize
(fun () ->
M.rpc connection string >>= fun result ->
match result with
| Ok x -> return x
| Error e ->
Printf.fprintf stderr "Caught: %s\n%!" (exn_to_string e);
fail e)
(fun () -> M.disconnect connection)

let make ?(timeout=30.) uri call =
let string = Xmlrpc.string_of_call call in
Expand Down

0 comments on commit d996786

Please # to comment.