search for: nbd_completion_callback

Displaying 20 results from an estimated 37 matches for "nbd_completion_callback".

2020 Sep 07
0
[libnbd PATCH 1/2] generator: Refactor handling of closures in unlocked functions
..._debug_callback (h); - h->debug_callback = debug_callback; + h->debug_callback = *debug_callback; return 0; } diff --git a/lib/opt.c b/lib/opt.c index cc0c145..003ecf8 100644 --- a/lib/opt.c +++ b/lib/opt.c @@ -74,7 +74,7 @@ nbd_unlocked_opt_go (struct nbd_handle *h) { int err; nbd_completion_callback c = { .callback = go_complete, .user_data = &err }; - int r = nbd_unlocked_aio_opt_go (h, c); + int r = nbd_unlocked_aio_opt_go (h, &c); if (r == -1) return r; @@ -96,7 +96,7 @@ nbd_unlocked_opt_info (struct nbd_handle *h) { int err; nbd_completion_callback c = { .callback...
2019 Aug 14
2
Re: [PATCH libnbd 1/4] api: Combine callback and user_data into a single struct.
...k is changed so that > the callback and user_data are combined into a single structure, eg: > > int64_t nbd_aio_pread (struct nbd_handle *h, > void *buf, size_t count, uint64_t offset, > - int (*completion_callback) (/*..*/), void *user_data, > + nbd_completion_callback completion_callback, > uint32_t flags); > > Several nbd_*_callback structures are defined. The one corresponding > to the example above is: > > typedef struct { > void *user_data; > int (*callback) (unsigned valid_flag, void *user_data, int *error);...
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 ++++++-----
2019 Aug 14
0
Re: [PATCH libnbd 1/4] api: Combine callback and user_data into a single struct.
...the callback and user_data are combined into a single structure, eg: > > > > int64_t nbd_aio_pread (struct nbd_handle *h, > > void *buf, size_t count, uint64_t offset, > > - int (*completion_callback) (/*..*/), void *user_data, > > + nbd_completion_callback completion_callback, > > uint32_t flags); > > > > Several nbd_*_callback structures are defined. The one corresponding > > to the example above is: > > > > typedef struct { > > void *user_data; > > int (*callback) (unsigned va...
2019 Aug 14
1
Re: [PATCH libnbd 1/4] api: Combine callback and user_data into a single struct.
On 8/14/19 4:21 AM, Richard W.M. Jones wrote: >>> The nbd_aio_pread function can now be called using: >>> >>> nbd_aio_pread (nbd, buf, sizeof buf, offset, >>> (nbd_completion_callback) { .callback = my_fn, >>> .user_data = my_data }, >> >> Is it worth arranging the C struct to match the typical argument >> ordering of user_data last? It doesn't make any real difference (the >> struct size doesn...
2019 Aug 13
0
[PATCH libnbd 1/4] api: Combine callback and user_data into a single struct.
...functions that take a callback is changed so that the callback and user_data are combined into a single structure, eg: int64_t nbd_aio_pread (struct nbd_handle *h, void *buf, size_t count, uint64_t offset, - int (*completion_callback) (/*..*/), void *user_data, + nbd_completion_callback completion_callback, uint32_t flags); Several nbd_*_callback structures are defined. The one corresponding to the example above is: typedef struct { void *user_data; int (*callback) (unsigned valid_flag, void *user_data, int *error); } nbd_completion_callback; The nbd_ai...
2019 Aug 13
0
[PATCH libnbd] api: Rename nbd_aio_*_callback to nbd_aio_*.
...nbd_unlocked_aio_pread_callback (h, buf, count, offset, NULL, NULL, - flags); -} - -int64_t -nbd_unlocked_aio_pread_callback (struct nbd_handle *h, void *buf, - size_t count, uint64_t offset, - nbd_completion_callback completion, - void *user_data, - uint32_t flags) + size_t count, uint64_t offset, + nbd_completion_callback completion, + void *user_data, + ui...
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 03
1
[PATCH libnbd] generator: Generate typedefs automatically for Closure arguments.
...re written by hand and only used internally to the library.) This change necessitates that we uniquely name all of our closures across methods (the same-named closure is required to have the same cbargs). I took this opportunity to rename some, so especially completion callbacks now have the type nbd_completion_callback. The generator also checks they are named uniquely. This does not change the C API or ABI. --- generator/generator | 93 +++++++++++++++++++++++------ generator/states-reply-simple.c | 12 ++-- generator/states-reply-structured.c | 40 ++++++------- generator/states-reply.c...
2019 Aug 13
2
[PATCH libnbd] api: Rename nbd_aio_*_callback to nbd_aio_*.
This applies on top of the OClosure v2 series posted a few minutes ago. Rich.
2019 Aug 14
2
[libnbd PATCH] lib: Consolidate free callbacks to just happen at retire time
...rnal.h @@ -277,20 +277,6 @@ struct command { #define CALL_CALLBACK(cb, ...) \ (cb).callback ((cb).user_data, ##__VA_ARGS__) -/* Free a callback. - * - * Note this works for any type of callback because the basic layout - * of the struct is the same for all of them. Therefore casting cb to - * nbd_completion_callback does not change the effective code. - */ -#define FREE_CALLBACK(cb) \ - do { \ - nbd_completion_callback *_cb = (nbd_completion_callback *)&(cb); \ - if (_cb->callback !=...
2019 Aug 13
0
[PATCH libnbd 3/4] lib: Add FREE_CALLBACK macro.
...--- a/lib/internal.h +++ b/lib/internal.h @@ -273,6 +273,20 @@ struct command { uint32_t error; /* Local errno value */ }; +/* Free a callback. + * + * Note this works for any type of callback because the basic layout + * of the struct is the same for all of them. Therefore casting cb to + * nbd_completion_callback does not change the effective code. + */ +#define FREE_CALLBACK(cb) \ + do { \ + nbd_completion_callback *_cb = (nbd_completion_callback *)&(cb); \ + if (_cb->callback !=...
2019 Aug 13
1
Re: [PATCH libnbd] api: Rename nbd_aio_*_callback to nbd_aio_*.
On 8/13/19 10:37 AM, Richard W.M. Jones wrote: > The original nbd_aio_* (non-callback) functions are removed and > replaced with the renamed callback variants. > > This is a simple mechanical change to the API: > > (1) Any existing call to nbd_aio_*_callback can simply be renamed to > nbd_aio_* > > (2) Any existing call to nbd_aio_* must have two extra NULL
2023 May 02
1
[libnbd PATCH v2 2/2] generator/C: lib/api.c: indent arg list 2 spaces relative to function name
...@@ -5378,9 +5577,11 @@ aio_opt_list_meta_context_queries_in_per > } > > int > -nbd_aio_opt_list_meta_context_queries (struct nbd_handle *h, char **queries, > - nbd_context_callback context_callback, > - nbd_completion_callback completion_callback) > +nbd_aio_opt_list_meta_context_queries ( > + struct nbd_handle *h, char **queries, > + nbd_context_callback context_callback, > + nbd_completion_callback completion_callback > +) > { > bool p; > int ret; Bugzilla: https://bugzilla.redhat.com...
2019 Aug 15
0
Re: [libnbd PATCH] lib: Consolidate free callbacks to just happen at retire time
...nd { > #define CALL_CALLBACK(cb, ...) \ > (cb).callback ((cb).user_data, ##__VA_ARGS__) > > -/* Free a callback. > - * > - * Note this works for any type of callback because the basic layout > - * of the struct is the same for all of them. Therefore casting cb to > - * nbd_completion_callback does not change the effective code. > - */ > -#define FREE_CALLBACK(cb) \ > - do { \ > - nbd_completion_callback *_cb = (nbd_completion_callback *)&(cb); \ > -...
2020 Aug 14
0
[libnbd PATCH v2 12/13] wip: api: Give aio_opt_go a completion callback
...return 0; } +static int +go_complete (void *opaque, int *err) +{ + int *i = opaque; + *i = *err; + return 0; +} + /* Issue NBD_OPT_GO (or NBD_OPT_EXPORT_NAME) and wait for the reply. */ int nbd_unlocked_opt_go (struct nbd_handle *h) { - int r = nbd_unlocked_aio_opt_go (h); + int err; + nbd_completion_callback c = { .callback = go_complete, .user_data = &err }; + int r = nbd_unlocked_aio_opt_go (h, c); if (r == -1) return r; r = wait_for_option (h); + if (r == 0) + r = err; if (r == 0 && nbd_internal_is_state_negotiating (get_next_state (h))) return -1; /* NBD_OPT_GO...
2023 May 02
4
[libnbd PATCH v2 0/2] continue wrapping generated C code harder
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2172516 v1: https://listman.redhat.com/archives/libguestfs/2023-April/031375.html In v2, move the declaration of the "p" helper variable next to the top of the function. Thanks! Laszlo Laszlo Ersek (2): generator/C: print_wrapper: use helper variable for permitted state check generator/C: lib/api.c: indent arg list 2
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.
.../* Call a callback. */ #define CALL_CALLBACK(cb, ...) \ (cb).callback ((cb).user_data, ##__VA_ARGS__) @@ -286,9 +291,9 @@ struct command { #define FREE_CALLBACK(cb) \ do { \ nbd_completion_callback *_cb = (nbd_completion_callback *)&(cb); \ - if (_cb->callback != NULL && _cb->free != NULL) \ + if (CALLBACK_IS_NOT_NULL (cb) && _cb->free != NULL) \ _cb->free (_cb->user_data);...
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
2020 Sep 28
0
[libnbd PATCH 3/3] api: Add nbd_opt_list_meta_context
...(-) diff --git a/lib/internal.h b/lib/internal.h index cde5dcd..ad1eeb9 100644 --- a/lib/internal.h +++ b/lib/internal.h @@ -77,6 +77,7 @@ struct command_cb { nbd_extent_callback extent; nbd_chunk_callback chunk; nbd_list_callback list; + nbd_context_callback context; } fn; nbd_completion_callback completion; }; diff --git a/generator/API.ml b/generator/API.ml index 938ace4..358ec38 100644 --- a/generator/API.ml +++ b/generator/API.ml @@ -142,8 +142,13 @@ let list_closure = { cbname = "list"; cbargs = [ CBString "name"; CBString "description" ] } +let co...