search for: caml_leave_blocking_section

Displaying 20 results from an estimated 55 matches for "caml_leave_blocking_section".

2023 Jun 27
1
[PATCH libguestfs 1/4] ocaml: Replace old enter/leave_blocking_section calls
Since OCaml 4 the old and confusing caml_enter_blocking_section and caml_leave_blocking_section calls have been replaced with caml_release_runtime_system and caml_acquire_runtime_system (in that order). Use the new names. --- generator/OCaml.ml | 5 +++-- ocaml/guestfs-c.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/generator/OCaml.ml b/generator/OCaml.ml inde...
2023 Jun 27
4
[PATCH libguestfs 0/4] Fix ups for OCaml 5
No action required here as I have pushed this already, this is just for your information. Rich.
2020 Sep 01
0
[nbdkit PATCH 2/2] ocaml: Implement .list_exports and friends
...escription_fn; static value can_cache_fn; static value can_extents_fn; @@ -311,6 +314,64 @@ preconnect_wrapper (int readonly) CAMLreturnT (int, 0); } +static int +list_exports_wrapper (int readonly, int is_tls, struct nbdkit_exports *exports) +{ + CAMLparam0 (); + CAMLlocal2 (rv, v); + + caml_leave_blocking_section (); + + rv = caml_callback2_exn (list_exports_fn, Val_bool (readonly), + Val_bool (is_tls)); + if (Is_exception_result (rv)) { + nbdkit_error ("%s", caml_format_exception (Extract_exception (rv))); + caml_enter_blocking_section (); + CAMLreturnT (int,...
2020 Sep 21
0
[nbdkit PATCH v3 14/14] ocaml: Implement .list_exports and friends
...escription_fn; static value can_cache_fn; static value can_extents_fn; @@ -311,6 +314,65 @@ preconnect_wrapper (int readonly) CAMLreturnT (int, 0); } +static int +list_exports_wrapper (int readonly, int is_tls, struct nbdkit_exports *exports) +{ + CAMLparam0 (); + CAMLlocal2 (rv, v); + + caml_leave_blocking_section (); + + rv = caml_callback2_exn (list_exports_fn, Val_bool (readonly), + Val_bool (is_tls)); + if (Is_exception_result (rv)) { + nbdkit_error ("%s", caml_format_exception (Extract_exception (rv))); + caml_enter_blocking_section (); + CAMLreturnT (int,...
2019 May 17
1
Re: [nbdkit PATCH v2 08/24] ocaml: Implement .cache script callback
On Wed, May 15, 2019 at 10:57:58PM -0500, Eric Blake wrote: > +static int > +can_cache_wrapper (void *h) > +{ > + CAMLparam0 (); > + CAMLlocal1 (rv); > + > + caml_leave_blocking_section (); > + > + rv = caml_callback_exn (can_cache_fn, *(value *) h); > + if (Is_exception_result (rv)) { > + nbdkit_error ("%s", caml_format_exception (Extract_exception (rv))); > + caml_enter_blocking_section (); > + CAMLreturnT (int, -1); > + } > + > +...
2023 May 27
2
[PATCH libguestfs 2/2] Only leave/enter blocking_section when OCaml lock is not held
...ff --git a/ocaml/guestfs-c.c b/ocaml/guestfs-c.c index 3888c9456..bcf8e6ab3 100644 --- a/ocaml/guestfs-c.c +++ b/ocaml/guestfs-c.c @@ -395,12 +395,16 @@ event_callback_wrapper (guestfs_h *g, /* Ensure we are holding the GC lock before any GC operations are * possible. (RHBZ#725824) */ - caml_leave_blocking_section (); + bool in_blocking_section = (caml_state == NULL); + + if (in_blocking_section) + caml_leave_blocking_section (); event_callback_wrapper_locked (g, data, event, event_handle, flags, buf, buf_len, array, array_len); - caml_enter_blocking_section ();...
2019 May 16
0
[nbdkit PATCH v2 08/24] ocaml: Implement .cache script callback
...--------*/ /* Wrapper functions that translate calls from C (ie. nbdkit) to OCaml. */ @@ -638,6 +641,48 @@ extents_wrapper (void *h, uint32_t count, uint64_t offset, uint32_t flags, CAMLreturnT (int, 0); } +static int +can_cache_wrapper (void *h) +{ + CAMLparam0 (); + CAMLlocal1 (rv); + + caml_leave_blocking_section (); + + rv = caml_callback_exn (can_cache_fn, *(value *) h); + if (Is_exception_result (rv)) { + nbdkit_error ("%s", caml_format_exception (Extract_exception (rv))); + caml_enter_blocking_section (); + CAMLreturnT (int, -1); + } + + caml_enter_blocking_section (); + CAMLretu...
2020 Feb 10
1
[nbdkit PATCH] ocaml: Support .preconnect callback
...---------------------------------*/ /* Wrapper functions that translate calls from C (ie. nbdkit) to OCaml. */ @@ -726,6 +728,25 @@ can_fast_zero_wrapper (void *h) CAMLreturnT (int, Bool_val (rv)); } +static int +preconnect_wrapper (int readonly) +{ + CAMLparam0 (); + CAMLlocal1 (rv); + + caml_leave_blocking_section (); + + rv = caml_callback_exn (preconnect_fn, Val_bool (readonly)); + if (Is_exception_result (rv)) { + nbdkit_error ("%s", caml_format_exception (Extract_exception (rv))); + caml_enter_blocking_section (); + CAMLreturnT (int, -1); + } + + caml_enter_blocking_section (); +...
2019 Aug 15
2
[nbdkit PATCH] ocaml: Add support for dynamic .thread_model
...---------*/ /* Wrapper functions that translate calls from C (ie. nbdkit) to OCaml. */ @@ -683,18 +686,30 @@ cache_wrapper (void *h, uint32_t count, uint64_t offset, uint32_t flags) CAMLreturnT (int, 0); } +static int +thread_model_wrapper (void) +{ + CAMLparam0 (); + CAMLlocal1 (rv); + + caml_leave_blocking_section (); + + rv = caml_callback_exn (config_complete_fn, Val_unit); + if (Is_exception_result (rv)) { + nbdkit_error ("%s", caml_format_exception (Extract_exception (rv))); + caml_enter_blocking_section (); + CAMLreturnT (int, -1); + } + + caml_enter_blocking_section (); + CAMLre...
2019 Apr 23
4
[PATCH nbdkit 0/2] Be careful not to leak heap memory to the client.
This bug was found by Eric Blake. In the .pread method we allocate a buffer in the server and pass it to the plugin. The plugin is supposed to fill it with data. The buffer was uninitialized so initially contained random heap data, but that's OK provided the plugin fully overwrote it with data. All correctly written plugins ought to do this, however there is the possibility of an
2019 Apr 23
0
[PATCH nbdkit 1/2] ocaml: Initialize pread buffer with zeroes to avoid leaking heap memory.
...ugins/ocaml/ocaml.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/ocaml/ocaml.c b/plugins/ocaml/ocaml.c index d854f48..7193842 100644 --- a/plugins/ocaml/ocaml.c +++ b/plugins/ocaml/ocaml.c @@ -444,6 +444,10 @@ pread_wrapper (void *h, void *buf, uint32_t count, uint64_t offset, caml_leave_blocking_section (); strv = caml_alloc_string (count); + /* Initialize the buffer with zeroes in case the plugin does not + * fill it completely. + */ + memset (String_val (strv), 0, count); offsetv = caml_copy_int64 (offset); flagsv = Val_flags (flags); -- 2.20.1
2020 Sep 01
4
[nbdkit PATCH 0/2] More language bindings for .list_exports
This picks up python and ocaml. Some of our languages are lacking a number of bindings (for example, lua and perl lack .extents, so I didn't have anything to copy from), and I felt less comfortable with golang and rust. But for python and ocaml, I was able to test a working implementation. Eric Blake (2): python: Implement .list_exports and friends ocaml: Implement .list_exports and
2019 Apr 23
0
[PATCH nbdkit v2 1/2] ocaml: Change pread method to avoid leaking heap memory.
...gins/ocaml/ocaml.c +++ b/plugins/ocaml/ocaml.c @@ -439,15 +439,16 @@ pread_wrapper (void *h, void *buf, uint32_t count, uint64_t offset, uint32_t flags) { CAMLparam0 (); - CAMLlocal4 (rv, strv, offsetv, flagsv); + CAMLlocal4 (rv, countv, offsetv, flagsv); + mlsize_t len; caml_leave_blocking_section (); - strv = caml_alloc_string (count); + countv = caml_copy_int32 (count); offsetv = caml_copy_int64 (offset); flagsv = Val_flags (flags); - value args[] = { *(value *) h, strv, offsetv, flagsv }; + value args[] = { *(value *) h, countv, offsetv, flagsv }; rv = caml_callbackN_exn...
2019 Jun 04
0
[PATCH libnbd v2 2/4] generator: Callback returns int instead of void.
...t;; - pr "static void\n"; + pr "static int\n"; pr "%s_%s_wrapper " name cb_name; print_c_arg_list args; pr "\n"; pr "{\n"; + pr " int ret;\n"; + pr "\n"; pr " caml_leave_blocking_section ();\n"; let c_argnames = List.flatten (List.map name_of_arg args) in - pr " %s_%s_wrapper_locked (%s);\n" name cb_name + pr " ret = %s_%s_wrapper_locked (%s);\n" name cb_name (String.concat ", " c_argnames); pr " caml...
2019 Jul 25
2
[libnbd PATCH] generator: Let nbd_aio_get_direction return unsigned
...quot;NULL" + | RUInt -> pr " unsigned r;\n"; None in pr "\n"; pr " caml_enter_blocking_section ();\n"; pr " r = nbd_%s " name; @@ -4757,14 +4781,17 @@ let print_ocaml_binding (name, { args; ret }) = pr ";\n"; pr " caml_leave_blocking_section ();\n"; pr "\n"; - pr " if (r == %s)\n" errcode; - pr " nbd_internal_ocaml_raise_error ();\n"; - pr "\n"; + (match errcode with + | Some code -> + pr " if (r == %s)\n" code; + pr " nbd_internal_ocaml_raise_err...
2019 Jul 24
0
[PATCH libnbd 2/3] lib: Implement closure lifetimes.
...name; - C.print_arg_list ~user_data:true cbargs; + C.print_arg_list ~valid_flag:true ~user_data:true cbargs; pr "\n"; pr "{\n"; - pr " int ret;\n"; + pr " int ret = 0;\n"; pr "\n"; - pr " caml_leave_blocking_section ();\n"; - pr " ret = %s_%s_wrapper_locked " name cbname; + pr " if (valid_flag & LIBNBD_CALLBACK_VALID) {\n"; + pr " caml_leave_blocking_section ();\n"; + pr " ret = %s_%s_wrapper_locked " name cbname; C.print_...
2014 Jan 08
5
hivex: Make node names and value names with embedded null characters accessible
On Windows, there exist at least two APIs for dealing with the Registry: The Win32 API (RegCreateKeyA, RegCreateKeyW, etc.) works with null-terminated ASCII or UTF-16 strings. The native API (ZwCreateKey, etc.), on the other hand works with UTF-16 strings that are stored as buffers+length and may contain null characters. Malware authors have been relying on the Win32 API's inability to
2019 Apr 23
4
[PATCH nbdkit v2 0/2] Be careful not to leak server heap memory to the client.
Version 1 was here: https://www.redhat.com/archives/libguestfs/2019-April/msg00144.html Version 2 makes a couple of much larger changes: The OCaml patch changes the API of the pread method so it matches what other language bindings are already doing, ie. get the language plugin to return a newly allocated buffer, check it is long enough, copy out the data. The server patch implements a
2019 Jul 24
0
[PATCH libnbd v2 2/5] lib: Implement closure lifetimes.
...name; - C.print_arg_list ~user_data:true cbargs; + C.print_arg_list ~valid_flag:true ~user_data:true cbargs; pr "\n"; pr "{\n"; - pr " int ret;\n"; + pr " int ret = 0;\n"; pr "\n"; - pr " caml_leave_blocking_section ();\n"; - pr " ret = %s_%s_wrapper_locked " name cbname; + pr " if (valid_flag & LIBNBD_CALLBACK_VALID) {\n"; + pr " caml_leave_blocking_section ();\n"; + pr " ret = %s_%s_wrapper_locked " name cbname; C.print_...
2019 Jul 24
0
[PATCH libnbd 1/3] generator: Change Closure so it describes single callbacks.
...pr "static int\n"; - pr "%s_%s_wrapper " name cbname; - C.print_arg_list ~user_data:true cbargs; - pr "\n"; - pr "{\n"; - pr " int ret;\n"; - pr "\n"; - pr " caml_leave_blocking_section ();\n"; - pr " ret = %s_%s_wrapper_locked " name cbname; - C.print_arg_list ~user_data:true ~types:false cbargs; - pr ";\n"; - pr " caml_enter_blocking_section ();\n"; - pr " return ret;\n"; -...