search for: nbd_set_debug_callback

Displaying 20 results from an estimated 40 matches for "nbd_set_debug_callback".

2019 Jul 20
2
[libnbd] More thoughts on callbacks and more
...r_data) as soon as the closure will no longer be called by the library. This function would be used to decrement the refcount from Python or remove the global root from OCaml. Note this is a family of functions, eg: nbd_set_free_set_debug_callback_debug_fn corresponding to the debug_fn arg of nbd_set_debug_callback. Luckily they can all be generated along with the internal machinery to call them. Buffer lifetimes ---------------- Similar to the above, persistent buffers (BytesPersist*) can have lifetimes. Remove nbd_add_close_callback ----------------------------- The above changes (actually, just the cl...
2019 Aug 14
2
Re: [PATCH libnbd 1/4] api: Combine callback and user_data into a single struct.
...cb, 0); where the omission of .member= designators may result in less typing, but only if the member order matches. > +++ b/docs/libnbd.pod > @@ -598,14 +598,25 @@ will use your login name): > > =head1 CALLBACKS > > -Some libnbd calls take function pointers (eg. > -C<nbd_set_debug_callback>, C<nbd_aio_pread>). Libnbd can call these > -functions while processing. > - > -Callbacks have an opaque C<void *user_data> pointer. This is passed > -as the second parameter to the callback. The opaque pointer is only > -used from the C API, since in other languag...
2019 Aug 14
3
[libnbd PATCH 0/2] Drop generated file from git
Rich recently patched things to generate one man page per function rather than libnbd-api.3 (nice), but in doing so got stumped by a problem with a fresh git clone (automake fails for any 'include' directive that does not already exist). I've figured out how to hack around it, but the hack requires GNU make. We already use GNU make constructs elsewhere (such as $(wildcard)), but
2019 Jul 22
3
Re: [libnbd] More thoughts on callbacks and more
...---------------- Here's a possibly better idea which still changes the API a bit but not as invasively. We overload the callback so that it can either be a callback function or a "free function". They are distinguished by an extra flag argument passed to the callback: extern int nbd_set_debug_callback ( struct nbd_handle *h, int (*debug_fn) (int valid_flag, // <-- note void *user_data, const char *context, const char *msg), void *user_data); The extra ‘valid_flag’ contains one or both of LIBNBD_CALLBACK_VALID and LIBNBD_CAL...
2019 Jul 22
0
Re: [libnbd] More thoughts on callbacks and more
...onger be called by the library. This function would be used to > decrement the refcount from Python or remove the global root from > OCaml. > > Note this is a family of functions, eg: > > nbd_set_free_set_debug_callback_debug_fn > > corresponding to the debug_fn arg of nbd_set_debug_callback. Luckily > they can all be generated along with the internal machinery to call > them. As written above this doesn't quite work. However it could work to pass an optional free function with the closure. In other words it would look like: struct nbd_closure { .cl = my_debug_fn,...
2019 Aug 13
1
Re: [PATCH libnbd 4/6] lib: Check Closure parameter is not NULL.
...ard W.M. Jones wrote: > This was not permitted by the API before, but would in some > circumstances work. > --- > generator/generator | 10 ++++++++++ > 1 file changed, 10 insertions(+) > Requires nbd_pread_structured and nbd_block_status to pass in a callback (good). Requires nbd_set_debug_callback to provide a non-NULL pointer (a bit rough, as now you can't pass NULL to deinstall your handler and get back to the default behavior - but how often are applications likely to deinstall a debug handler? If it becomes a problem, we can improve the 'closure' type to take a bool argument...
2019 Aug 14
0
Re: [PATCH libnbd 1/4] api: Combine callback and user_data into a single struct.
...rrangement when all 3 members are present? I guess { callback, user_data, free }? > > +++ b/docs/libnbd.pod > > @@ -598,14 +598,25 @@ will use your login name): > > > > =head1 CALLBACKS > > > > -Some libnbd calls take function pointers (eg. > > -C<nbd_set_debug_callback>, C<nbd_aio_pread>). Libnbd can call these > > -functions while processing. > > - > > -Callbacks have an opaque C<void *user_data> pointer. This is passed > > -as the second parameter to the callback. The opaque pointer is only > > -used from the C AP...
2019 Aug 13
1
Re: [PATCH libnbd 1/7] api: Add semi-private function for freeing persistent data.
On Mon, Aug 12, 2019 at 11:00:01PM +0100, Richard W.M. Jones wrote: > On Mon, Aug 12, 2019 at 01:53:56PM -0500, Eric Blake wrote: > > We then have the design question of whether to make an OClosure type, > > where C has two functions nbd_aio_pread and nbd_aio_pread_callback for > > convenience, but where other languages have only a single nbd.aio_pread > > where the
2019 Aug 13
1
Re: [PATCH libnbd v2 3/3] api: Add nbd_clear_debug_callback.
...args = []; > + ret = RErr; Is RErr the right type, or can we make this a 'never fails' function? > + shortdesc = "clear the debug callback"; > + longdesc = "\ > +Remove the debug callback if one was previously associated > +with the handle (with C<nbd_set_debug_callback>). If not s/not/no/ > +callback was associated this does nothing."; > }; > > "set_handle_name", { > diff --git a/lib/debug.c b/lib/debug.c > index ad4d9cb..c1decb2 100644 > --- a/lib/debug.c > +++ b/lib/debug.c > @@ -38,13 +38,24 @@ nbd_unlocked...
2019 Jul 25
0
[PATCH libnbd v3 1/2] lib: Implement closure lifetimes.
...this callback will never be needed or called again), it is called once more with valid_flag == LIBNBD_CALLBACK_FREE. (Note it is also possible for the library to call the callback with valid_flag == LIBNBD_CALLBACK_VALID|LIBNBD_CALLBACK_FREE, meaning it's the last valid call.) As an example, nbd_set_debug_callback registers a debug closure which is saved in the handle. The closure is freed either when nbd_set_debug_callback is called again, or the handle is closed. The sequence of events would look like this: Caller Callback nbd_set_debug_callback # a new deb...
2019 Aug 14
1
Re: [PATCH libnbd 1/4] api: Combine callback and user_data into a single struct.
...s. > > Sure. What would be the arrangement when all 3 members are > present? I guess { callback, user_data, free }? Yes, I think that's the most convenient arrangement based on which fields are most likely to be left NULL. >>> +Some libnbd calls take callbacks (eg. C<nbd_set_debug_callback>, >> >> 2 spaces looks odd (emacs thinks eg. ended a sentence) > > OK fixed in my copy. > > Interesting fact about emacs I-search: It doesn't let you search for > double spaces for some reason. Yeah, emacs intentionally treats all runs of 1 or more spaces in tex...
2019 Jul 24
0
[PATCH libnbd 2/3] lib: Implement closure lifetimes.
...this callback will never be needed or called again), it is called once more with valid_flag == LIBNBD_CALLBACK_FREE. (Note it is also possible for the library to call the callback with valid_flag == LIBNBD_CALLBACK_VALID|LIBNBD_CALLBACK_FREE, meaning it's the last valid call.) As an example, nbd_set_debug_callback registers a debug closure which is saved in the handle. The closure is freed either when nbd_set_debug_callback is called again, or the handle is closed. The sequence of events would look like this: Caller Callback nbd_set_debug_callback # a new deb...
2019 Jul 25
4
[PATCH libnbd v3 0/2] lib: Implement closure lifetimes.
I think I've addressed everything that was raised in review. Some of the highlights: - Callbacks should be freed reliably along all exit paths. - There's a simple test of closure lifetimes. - I've tried to use VALID|FREE in all the places where I'm confident that it's safe and correct to do. There may be more places. Note this is an optimization and shouldn't
2019 Aug 13
1
Re: [PATCH libnbd] api: Rename nbd_aio_*_callback to nbd_aio_*.
...a low level asynchronous equivalents (eg. C<nbd_aio_pread> for equivalent > +starting a command). > > =head2 glib2 integration > > @@ -600,8 +599,8 @@ will use your login name): > =head1 CALLBACKS > > Some libnbd calls take function pointers (eg. > -C<nbd_set_debug_callback>, C<nbd_pread_callback>). Libnbd can call Eww - we had a bogus link (that should have been nbd_aio_pread_callback). Nice that we fix that as a side effect. > -these functions while processing. > +C<nbd_set_debug_callback>, C<nbd_aio_pread>). Libnbd can call these >...
2023 Jul 16
2
[libnbd PATCH] api: Fix block status assertion under set_strict bypass
On Sat, Jul 15, 2023 at 08:49:51PM -0500, Eric Blake wrote: > A compliant server should not send NBD_REPLY_TYPE_BLOCK_STATUS unless > we successfully negotiated a meta context. And our default strictness > settings refuse to let us send NBD_CMD_BLOCK_STATUS unless we > negotiated a meta context. But when you mix non-default settings > (using nbd_set_strict to disable
2019 Aug 12
0
[PATCH libnbd 7/7] api: Remove the valid_flag from all callbacks.
...re valid and this is a normal callback. - -=item C<LIBNBD_CALLBACK_FREE> - -This is the last time the library will call this function. Any data -associated with the callback can be freed. - -=item other bits - -Other bits in C<valid_flag> should be ignored. - -=back - -For example C<nbd_set_debug_callback> sets up a callback which you -could define like this: - - int my_debug_fn (unsigned valid_flag, void *user_data, - const char *context, const char *msg) - { - if (valid_flag & LIBNBD_CALLBACK_VALID) { - printf ("context = %s, msg = %s\n", context, msg); -...
2019 Jul 24
0
[PATCH libnbd v2 2/5] lib: Implement closure lifetimes.
...this callback will never be needed or called again), it is called once more with valid_flag == LIBNBD_CALLBACK_FREE. (Note it is also possible for the library to call the callback with valid_flag == LIBNBD_CALLBACK_VALID|LIBNBD_CALLBACK_FREE, meaning it's the last valid call.) As an example, nbd_set_debug_callback registers a debug closure which is saved in the handle. The closure is freed either when nbd_set_debug_callback is called again, or the handle is closed. The sequence of events would look like this: Caller Callback nbd_set_debug_callback # a new deb...
2019 Aug 13
0
[PATCH libnbd 1/4] api: Combine callback and user_data into a single struct.
...23 files changed, 226 insertions(+), 182 deletions(-) diff --git a/docs/libnbd.pod b/docs/libnbd.pod index b38def0..9177825 100644 --- a/docs/libnbd.pod +++ b/docs/libnbd.pod @@ -598,14 +598,25 @@ will use your login name): =head1 CALLBACKS -Some libnbd calls take function pointers (eg. -C<nbd_set_debug_callback>, C<nbd_aio_pread>). Libnbd can call these -functions while processing. - -Callbacks have an opaque C<void *user_data> pointer. This is passed -as the second parameter to the callback. The opaque pointer is only -used from the C API, since in other languages you can use closures t...
2019 Aug 13
0
[PATCH libnbd 2/4] api: Add free function and remove valid_flag parameter.
...ack = my_fn>> function is called. -=item C<LIBNBD_CALLBACK_FREE> - -This is the last time the library will call this function. Any data -associated with the callback can be freed. - -=item other bits - -Other bits in C<valid_flag> should be ignored. - -=back - -For example C<nbd_set_debug_callback> sets up a callback which you -could define like this: - - int my_debug_fn (unsigned valid_flag, void *user_data, - const char *context, const char *msg) - { - if (valid_flag & LIBNBD_CALLBACK_VALID) { - printf ("context = %s, msg = %s\n", context, msg); -...
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