Displaying 20 results from an estimated 41 matches for "s_callback".
2019 Aug 14
4
[PATCH libnbd 0/2] Use free callback to dereference NBD.Buffer.
In this patch series we use the newly introduced free callback
on the completion function to dererence the OCaml NBD.Buffer.
I will make the same kind of change for Python later in a
separate series.
The completion function is always called at the C level, even
if the OCaml program didn't use the optional argument. That's
because the free callback doesn't run otherwise.
There is a
2019 Aug 14
0
[PATCH libnbd 2/2] ocaml: Remove NBD.Buffer.free function, use the completion callback instead.
...n";
+ pr " if (data->fnv == 0)\n";
+ pr " CAMLreturnT (int, 0);\n";
List.iter (
function
@@ -5079,19 +5080,19 @@ let print_ocaml_binding (name, { args; optargs; ret }) =
List.iter (
function
| OClosure { cbname } ->
- pr " nbd_%s_callback %s_callback = {0};\n" cbname cbname;
+ pr " nbd_%s_callback %s_callback;\n" cbname cbname;
+ pr " struct user_data *%s_user_data = alloc_user_data ();\n" cbname;
pr " if (%sv != Val_int (0)) { /* Some closure */\n" cbname;
pr "...
2019 Aug 15
13
[PATCH libnbd v2 00/10] Callbacks and OCaml and Python persistent buffers.
This is a combination of these two earlier series:
https://www.redhat.com/archives/libguestfs/2019-August/msg00235.html
https://www.redhat.com/archives/libguestfs/2019-August/msg00240.html
plus changes to allow .callback = NULL / .free != NULL, and to reduce
the complexity of freeing callbacks.
Although it's rather long there's nothing complex here. We might
consider squashing some
2019 Aug 13
0
[PATCH libnbd 1/4] api: Combine callback and user_data into a single struct.
.../generator
index 4d3d7ad..ea32929 100755
--- a/generator/generator
+++ b/generator/generator
@@ -3226,10 +3226,7 @@ let rec print_arg_list ?(handle = false) ?(types = true) args optargs =
pr "%s" len
| Closure { cbname; cbargs } ->
if types then pr "nbd_%s_callback " cbname;
- pr "%s_callback" cbname;
- pr ", ";
- if types then pr "void *";
- pr "%s_user_data" cbname
+ pr "%s_callback" cbname
| Enum (n, _) ->
if types then pr "int ";...
2020 Sep 08
2
Re: [libnbd PATCH 1/2] generator: Refactor handling of closures in unlocked functions
...ypes ?closure_mark args optargs;
> + if parens then pr ")"
> +
> +and print_arg_list' ?(handle = false) ?(types = true) ?(closure_mark = "")
...
> args optargs =
> | Closure { cbname; cbargs } ->
> if types then pr "nbd_%s_callback " cbname;
> - pr "%s_callback" cbname
> + pr "%s%s_callback" closure_mark cbname
Perhaps make it type safe?
type closure_mark = AddressOf | Dereference
And then:
pr "%s%c_callback"
(match closure_mark with AddressOf -> '&a...
2019 Aug 13
0
[PATCH libnbd 5/6] generator: Implement OClosure.
...or. *)
List.iter (
function
@@ -3377,6 +3368,12 @@ let rec print_arg_list ?(handle = false) ?(types = true) args optargs =
if !comma then pr ", ";
comma := true;
match optarg with
+ | OClosure { cbname; cbargs } ->
+ if types then pr "nbd_%s_callback " cbname;
+ pr "%s_callback" cbname;
+ pr ", ";
+ if types then pr "void *";
+ pr "%s_user_data" cbname
| OFlags (n, _) ->
if types then pr "uint32_t ";
pr "%s" n
@@ -3707,...
2019 Aug 13
0
[PATCH libnbd v2 1/3] generator: Implement OClosure.
...alse" name
| _ -> ()
@@ -3388,6 +3380,12 @@ let rec print_arg_list ?(handle = false) ?(types = true) args optargs =
if !comma then pr ", ";
comma := true;
match optarg with
+ | OClosure { cbname; cbargs } ->
+ if types then pr "nbd_%s_callback " cbname;
+ pr "%s_callback" cbname;
+ pr ", ";
+ if types then pr "void *";
+ pr "%s_user_data" cbname
| OFlags (n, _) ->
if types then pr "uint32_t ";
pr "%s" n
@@ -3718,...
2019 Aug 13
8
[PATCH libnbd 0/4] Add free function to callbacks.
Patches 1 & 2 are rather complex, but the end result is that we pass
closures + user_data + free function in single struct parameters as I
described previously in this email:
https://www.redhat.com/archives/libguestfs/2019-August/msg00210.html
Patch 3 adds a convenient FREE_CALLBACK macro which seems a worthwhile
simplification if you buy into 1 & 2.
Patch 4 adds another macro which is
2019 Aug 13
0
[PATCH libnbd 2/4] api: Add free function and remove valid_flag parameter.
...ypes then pr "void *";
pr "user_data";
@@ -3340,6 +3335,7 @@ let print_closure_structs () =
pr " int (*callback) ";
print_cbarg_list cbargs;
pr ";\n";
+ pr " void (*free) (void *user_data);\n";
pr "} nbd_%s_callback;\n" cbname;
pr "\n";
) all_closures;
@@ -3418,9 +3414,6 @@ let generate_include_libnbd_h () =
pr "#define %-40s %d\n" n i
) constants;
pr "\n";
- pr "#define LIBNBD_CALLBACK_VALID 1\n";
- pr "#define LIBNBD_CALLBACK_FREE 2\...
[PATCH libnbd v2 02/10] lib: Add macros to check if a callback is "null" or not, and set it to null.
2019 Aug 15
0
[PATCH libnbd v2 02/10] lib: Add macros to check if a callback is "null" or not, and set it to null.
...b/generator/generator
index ca97910..98c99e0 100755
--- a/generator/generator
+++ b/generator/generator
@@ -3576,7 +3576,7 @@ let generate_lib_api_c () =
let value = match errcode with
| Some value -> value
| None -> assert false in
- pr " if (%s_callback.callback == NULL) {\n" cbname;
+ pr " if (CALLBACK_IS_NULL (%s_callback)) {\n" cbname;
pr " set_error (EFAULT, \"%%s cannot be NULL\", \"%s\");\n" cbname;
pr " ret = %s;\n" value;
pr " goto o...
2020 Sep 07
0
[libnbd PATCH 1/2] generator: Refactor handling of closures in unlocked functions
...pes = true) args optargs =
let comma = ref false in
if handle then (
comma := true;
@@ -137,7 +138,7 @@ and print_arg_list' ?(handle = false) ?(types = true) args optargs =
pr "%s" len
| Closure { cbname; cbargs } ->
if types then pr "nbd_%s_callback " cbname;
- pr "%s_callback" cbname
+ pr "%s%s_callback" closure_mark cbname
| Enum (n, _) ->
if types then pr "int ";
pr "%s" n
@@ -179,19 +180,19 @@ and print_arg_list' ?(handle = false) ?(types = true)...
2019 Aug 13
2
Re: [PATCH libnbd 5/6] generator: Implement OClosure.
...n 8/13/19 5:06 AM, Richard W.M. Jones wrote:
> An optional Closure parameter, but otherwise works the same way as
> Closure.
> @@ -3778,6 +3777,7 @@ let generate_lib_api_c () =
> ) args;
> List.iter (
> function
> + | OClosure { cbname } -> pr ", %s_callback ? \"<fun>\" : \"NULL\"" cbname
Well, it also permits a NULL fn pointer.
> @@ -4383,6 +4387,16 @@ let print_python_binding name { args; optargs; ret; may_set_error } =
> ) args;
> List.iter (
> function
> + | OClosure { cbname } ->
>...
2020 Sep 07
4
[libnbd PATCH 0/2] Fix memory leak with closures
As promised in my earlier thread on libnbd completion callback question.
Eric Blake (2):
generator: Refactor handling of closures in unlocked functions
generator: Free closures on failure
docs/libnbd.pod | 2 +-
generator/C.ml | 48 +++++++++++------
generator/C.mli | 1 +
lib/debug.c | 7 +--
lib/opt.c | 31 ++++++-----
2020 Sep 11
0
[libnbd PATCH v2 2/5] generator: Refactor filtering of accepted OFlags
...tor/C.ml
index 4d4958d..86d9c5c 100644
--- a/generator/C.ml
+++ b/generator/C.ml
@@ -191,7 +191,7 @@ and print_arg_list' ?(handle = false) ?(types = true) ?(closure_style = Direct)
| AddressOf -> "&"
| Pointer -> "*" in
pr "%s%s_callback" mark cbname
- | OFlags (n, _) ->
+ | OFlags (n, _, _) ->
if types then pr "uint32_t ";
pr "%s" n
) optargs
@@ -494,11 +494,21 @@ let generate_lib_api_c () =
);
(* Check parameters are valid. *)
- let print_flags_check n...
2019 Aug 12
0
[PATCH libnbd 5/7] ocaml: Use free callback to free closure root, instead of valid_flag == FREE.
...args; optargs; ret }) =
pr " if (%s_user_data == NULL) caml_raise_out_of_memory ();\n" cbname;
pr " *%s_user_data = %sv;\n" cbname cbname;
pr " caml_register_generational_global_root (%s_user_data);\n" cbname;
- pr " const void *%s_callback = %s_%s_wrapper;\n" cbname name cbname
+ pr " const void *%s_callback = %s_%s_wrapper;\n" cbname name cbname;
+ pr " if (nbd_add_free_callback (h, %s_user_data,\n" cbname;
+ pr " free_root, %s_user_data) == -1)\n"
+...
2019 Aug 13
12
[PATCH 0/6] Implement OClosure.
Patches 1-4 are basically uncontroversial, straightforward refactoring
and IMHO we should just push them. Possibly 1-3 should be squashed
together, but I posted them separately so they are easier to review.
Patches 5 and 6 together implement OClosure. Patch 5 adds the feature
and is simple to understand.
Patch 6 changes the Closure completion callbacks into OClosure, but
because it doesn't
2019 Aug 13
7
[PATCH libnbd v2 0/3] Implement OClosures.
v1 was here:
https://www.redhat.com/archives/libguestfs/2019-August/msg00168.html
I pushed uncontroversial patches 1-4
v2:
- The implementation of OClosure (new patch 1) in Python is fixed.
- Patch 2 (old patch 5) is unchanged.
- I added a new API for removing debug callbacks. I think this
approach has some advantages over using OClosure.
- I didn't yet do any work on changing the
2019 Aug 14
5
[PATCH libnbd 0/3] Use free callback to hold ref to AIO buffer.
Basically the same as this patch series, but for Python:
https://www.redhat.com/archives/libguestfs/2019-August/msg00235.html
plus adding the 590 asynch test at the end.
Rich.
2019 Aug 10
0
[PATCH libnbd 6/9] generator: Add non-optional Flags type.
...lags of string * flags (* flags, uint32_t in C *)
| Int of string (* small int *)
| Int64 of string (* 64 bit signed int *)
| Path of string (* filename or path *)
@@ -3324,6 +3325,7 @@ let rec name_of_arg = function
| Closure { cbname } ->
[ sprintf "%s_callback" cbname; sprintf "%s_user_data" cbname ]
| Enum (n, _) -> [n]
+| Flags (n, _) -> [n]
| Int n -> [n]
| Int64 n -> [n]
| Path n -> [n]
@@ -3371,6 +3373,9 @@ let rec print_arg_list ?(handle = false) ?(types = true) args optargs =
| Enum (n, _) ->
i...
2019 Aug 03
1
[PATCH libnbd] generator: Generate typedefs automatically for Closure arguments.
...-3170,7 +3213,8 @@ let rec name_of_arg = function
| BytesOut (n, len) -> [n; len]
| BytesPersistIn (n, len) -> [n; len]
| BytesPersistOut (n, len) -> [n; len]
-| Closure { cbname } -> [cbname; sprintf "%s_user_data" cbname ]
+| Closure { cbname } ->
+ [ sprintf "%s_callback" cbname; sprintf "%s_user_data" cbname ]
| Flags n -> [n]
| Int n -> [n]
| Int64 n -> [n]
@@ -3232,12 +3276,8 @@ let rec print_arg_list ?(handle = false) ?(valid_flag = false)
if types then pr "size_t ";
pr "%s" len
| Closure...