From 833a13da58c506312424567ace7641488d9ffa28 Mon Sep 17 00:00:00 2001 From: John Anderson Date: Sun, 6 Nov 2022 20:35:35 -0500 Subject: [PATCH] add Socket.set_stream_notify --- zmq/src/caml_zmq_stubs.c | 1 + zmq/src/zmq.ml | 4 ++++ zmq/src/zmq.mli | 1 + zmq/test/zmq_test.ml | 7 +++++++ 4 files changed, 13 insertions(+) diff --git a/zmq/src/caml_zmq_stubs.c b/zmq/src/caml_zmq_stubs.c index 1d53244..3b2ce81 100644 --- a/zmq/src/caml_zmq_stubs.c +++ b/zmq/src/caml_zmq_stubs.c @@ -249,6 +249,7 @@ static int const native_int_option_for[] = { ZMQ_REQ_CORRELATE, ZMQ_REQ_RELAXED, ZMQ_CONFLATE, + ZMQ_STREAM_NOTIFY }; CAMLprim value caml_zmq_set_int_option(value socket, value option_name, value socket_option) { diff --git a/zmq/src/zmq.ml b/zmq/src/zmq.ml index 4c0e3d7..5b5f3bf 100644 --- a/zmq/src/zmq.ml +++ b/zmq/src/zmq.ml @@ -191,6 +191,7 @@ module Socket = struct | ZMQ_REQ_CORRELATE | ZMQ_REQ_RELAXED | ZMQ_CONFLATE + | ZMQ_STREAM_NOTIFY [@@@warning "+37"] external set_int_option : @@ -483,6 +484,9 @@ module Socket = struct let set_conflate socket flag = set_int_option socket ZMQ_CONFLATE (if flag then 1 else 0) + let set_stream_notify socket stream_notify_flag = + set_int_option socket ZMQ_STREAM_NOTIFY (if stream_notify_flag then 1 else 0) + external get_fd : 'a t -> Unix.file_descr = "caml_zmq_get_fd" type event = No_event | Poll_in | Poll_out | Poll_in_out | Poll_error diff --git a/zmq/src/zmq.mli b/zmq/src/zmq.mli index 2ee18bd..68e7cbc 100644 --- a/zmq/src/zmq.mli +++ b/zmq/src/zmq.mli @@ -232,6 +232,7 @@ module Socket : sig val set_zap_domain : 'a t -> string -> unit val get_zap_domain : 'a t -> string val set_conflate : [< `Pull | `Push | `Sub | `Pub | `Dealer] t -> bool -> unit + val set_stream_notify : [< `Stream ] t -> bool -> unit val get_fd : 'a t -> Unix.file_descr diff --git a/zmq/test/zmq_test.ml b/zmq/test/zmq_test.ml index 95972aa..a08b913 100644 --- a/zmq/test/zmq_test.ml +++ b/zmq/test/zmq_test.ml @@ -79,6 +79,13 @@ let test_socket_options () = test_set_get_value "Tcp keepalive interval" set_tcp_keepalive_interval get_tcp_keepalive_interval socket (`Value 1000); Socket.close socket; + + (* Must be a `Stream. No getter so just test that it doesn't explode. *) + let stream_socket = create ctx stream in + set_stream_notify stream_socket true; + set_stream_notify stream_socket false; + Socket.close stream_socket; + Context.terminate ctx; ()