mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-09 20:33:36 -04:00
feat(curl-client): block some signals in background thread(s)
This commit is contained in:
parent
8f2a666a70
commit
6722c49bb0
1 changed files with 10 additions and 3 deletions
|
|
@ -285,6 +285,14 @@ let mk_push (type a) ?batch () : (module PUSH with type elt = a) * (on_full_cb -
|
||||||
in
|
in
|
||||||
push, ((:=) on_full)
|
push, ((:=) on_full)
|
||||||
|
|
||||||
|
(* start a thread in the background, running [f()] *)
|
||||||
|
let start_bg_thread (f: unit -> unit) : unit =
|
||||||
|
let run() =
|
||||||
|
(* block some signals: USR1 USR2 TERM PIPE ALARM STOP, see [$ kill -L] *)
|
||||||
|
ignore (Thread.sigmask Unix.SIG_BLOCK [10; 12; 13; 14; 15; 19] : _ list);
|
||||||
|
f()
|
||||||
|
in
|
||||||
|
ignore (Thread.create run () : Thread.t)
|
||||||
|
|
||||||
(* make an emitter.
|
(* make an emitter.
|
||||||
|
|
||||||
|
|
@ -417,7 +425,7 @@ let mk_emitter ~(config:Config.t) () : (module EMITTER) =
|
||||||
C.cleanup();
|
C.cleanup();
|
||||||
end
|
end
|
||||||
in
|
in
|
||||||
let _th_process_batches: Thread.t = Thread.create bg_thread () in
|
start_bg_thread bg_thread;
|
||||||
|
|
||||||
let wakeup () =
|
let wakeup () =
|
||||||
with_mutex_ m (fun () -> Condition.signal cond);
|
with_mutex_ m (fun () -> Condition.signal cond);
|
||||||
|
|
@ -441,8 +449,7 @@ let mk_emitter ~(config:Config.t) () : (module EMITTER) =
|
||||||
done
|
done
|
||||||
in
|
in
|
||||||
|
|
||||||
let _th_ticker : Thread.t = Thread.create tick_thread () in
|
start_bg_thread tick_thread;
|
||||||
()
|
|
||||||
);
|
);
|
||||||
|
|
||||||
let module M = struct
|
let module M = struct
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue