Skip to content

Commit

Permalink
Merge pull request #274 from terrateamio/268-fix-curl-handle-leak
Browse files Browse the repository at this point in the history
#268 FIX Clean up Curl handle in case of failure
  • Loading branch information
orbitz authored Jan 29, 2025
2 parents 11a7a53 + 3ff7d6a commit 4c51515
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions code/src/abb_curl_easy/abb_curl_easy.ml
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,8 @@ module Make (Abb : Abb_intf.S with type Native.t = Unix.file_descr) = struct
CCString.length s)

let perform options headers meth_ uri =
let handle = Curl.init () in
try
let handle = Curl.init () in
Logs.debug (fun m -> Curl.set_verbose handle true);
CCList.iter
(function
Expand All @@ -438,7 +438,9 @@ module Make (Abb : Abb_intf.S with type Native.t = Unix.file_descr) = struct
in
Curl.cleanup handle;
Ok ({ Response.status; headers = !resp_headers }, Buffer.contents resp_body)
with Curl.CurlException (_, _, err) -> Error (`Curl_request_err err)
with Curl.CurlException (_, _, err) ->
Curl.cleanup handle;
Error (`Curl_request_err err)

let call ?(options = Options.default) ?(headers = Headers.empty) meth_ uri =
let open Abb.Future.Infix_monad in
Expand Down

0 comments on commit 4c51515

Please sign in to comment.