From 1a8cab85f1cb026f81716a333d9ebff623806eb2 Mon Sep 17 00:00:00 2001 From: ygrek Date: Sun, 18 Feb 2018 12:27:41 -0800 Subject: [PATCH] Multi.wait: fix --- curl-helper.c | 8 +++----- curl.ml | 3 ++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/curl-helper.c b/curl-helper.c index a4bf8dd..6e0db43 100644 --- a/curl-helper.c +++ b/curl-helper.c @@ -3997,18 +3997,16 @@ value caml_curlm_remove_finished(value v_multi) value caml_curl_multi_wait(value v_timeout_ms, value v_multi) { - CAMLparam1(v_multi); + CAMLparam2(v_timeout_ms,v_multi); CURLM *multi_handle = CURLM_val(v_multi); - int timeout_ms = 1000; + int timeout_ms = Int_val(v_timeout_ms); int numfds = -1; CURLMcode ret; - if (v_timeout_ms != Val_int(0)) - timeout_ms = Int_val(Field(0, v_timeout_ms)); - caml_enter_blocking_section(); ret = curl_multi_wait(multi_handle, NULL, 0, timeout_ms, &numfds); caml_leave_blocking_section(); + if (ret != CURLM_OK) caml_failwith("caml_curl_multi_wait"); CAMLreturn(Val_bool(numfds != 0)); diff --git a/curl.ml b/curl.ml index 18ed7ff..b5e52ce 100644 --- a/curl.ml +++ b/curl.ml @@ -1337,7 +1337,8 @@ module Multi = struct external create : unit -> mt = "caml_curl_multi_init" external add : mt -> t -> unit = "caml_curl_multi_add_handle" external perform : mt -> int = "caml_curl_multi_perform_all" - external wait : ?timeout_ms:int -> mt -> bool = "caml_curl_multi_wait" + external wait : int -> mt -> bool = "caml_curl_multi_wait" + let wait ?(timeout_ms=1000) mt = wait timeout_ms mt external remove : mt -> t -> unit = "caml_curl_multi_remove_handle" external remove_finished : mt -> (t * curlCode) option = "caml_curlm_remove_finished" external cleanup : mt -> unit = "caml_curl_multi_cleanup" -- 2.11.4.GIT