search for: my_debug_fn

Displaying 15 results from an estimated 15 matches for "my_debug_fn".

2019 Jul 20
2
[libnbd] More thoughts on callbacks and more
More thoughts on callbacks, etc. following on from: https://www.redhat.com/archives/libguestfs/2019-July/thread.html#00184 Closure lifetimes ----------------- Closures could have a lifetime if we had a little bit of support from the C library. We would generate (from C only): nbd_set_free_<fn>_<closure> (nbd, free_closure); which calls free_closure (user_data) as soon as the
2019 Jul 22
3
Re: [libnbd] More thoughts on callbacks and more
...g_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_CALLBACK_FREE. Callback code would look like: int my_debug_fn (int valid_flag, void *user_data, const char *context, const char *msg) { if (valid_flag & LIBNBD_CALLBACK_VALID) { // This is the normal callback as before. printf ("debug msg = %s\n", msg); } if (valid_flag & LIBNBD_CALLBACK_FREE) {...
2019 Jul 22
0
Re: [libnbd] More thoughts on callbacks and more
...et_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, .user_data = foo, .free = my_free } cl; nbd_set_debug_callback (nbd, &cl); cl->free (cl->user_data) is called if cl->free != NULL when the closure is no longer used by the library. This is a bit of a change to the API however. Rich. -- Richard Jones, Virt...
2019 Jul 22
0
Re: [libnbd] More thoughts on callbacks and more
...ack at the time it is ready to retire. But this idea does make it possible for libnbd to inform the callback about its last expected use. > > The extra ‘valid_flag’ contains one or both of LIBNBD_CALLBACK_VALID > and LIBNBD_CALLBACK_FREE. Callback code would look like: > > int my_debug_fn (int valid_flag, void *user_data, > const char *context, const char *msg) > { > if (valid_flag & LIBNBD_CALLBACK_VALID) { > // This is the normal callback as before. > printf ("debug msg = %s\n", msg); > } > > if (v...
2019 Jul 24
2
Re: [PATCH libnbd 2/3] lib: Implement closure lifetimes.
...for now and only set later if the client opts in to whatever the new bits are useful for? But I'm okay with leaving this sentence as worded. > + > +=back > + > +For example C<nbd_set_debug_callback> sets up a callback which you > +could define like this: > + > + int my_debug_fn (int 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); > + } > + if (valid_flag & LIBNBD_CALLBACK_FREE) { &g...
2019 Jul 24
0
[PATCH libnbd 2/3] lib: Implement closure lifetimes.
..._fn is called calls any nbd function debug_fn (valid_flag == VALID) debug_fn (valid_flag == VALID) # the second debug_fn is freed nbd_close debug_fn (valid_flag == FREE) An example of a debug_fn written by a caller would be: int my_debug_fn (int 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); } if (valid_flag & LIBNBD_CALLBACK_FREE) { /* If you need to free something,...
2019 Jul 24
0
[PATCH libnbd v2 2/5] lib: Implement closure lifetimes.
..._fn is called calls any nbd function debug_fn (valid_flag == VALID) debug_fn (valid_flag == VALID) # the second debug_fn is freed nbd_close debug_fn (valid_flag == FREE) An example of a debug_fn written by a caller would be: int my_debug_fn (int 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); } if (valid_flag & LIBNBD_CALLBACK_FREE) { /* If you need to free something,...
2019 Jul 25
0
[PATCH libnbd v3 1/2] lib: Implement closure lifetimes.
..._fn is called calls any nbd function debug_fn (valid_flag == VALID) debug_fn (valid_flag == VALID) # the second debug_fn is freed nbd_close debug_fn (valid_flag == FREE) An example of a debug_fn written by a caller would be: int my_debug_fn (int 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); } if (valid_flag & LIBNBD_CALLBACK_FREE) { /* If you need to free something,...
2019 Aug 12
0
[PATCH libnbd 7/7] api: Remove the valid_flag from all callbacks.
...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); - } - if (valid_flag & LIBNBD_CALLBACK_FREE) { - /* If you need to fre...
2019 Aug 13
0
[PATCH libnbd 2/4] api: Add free function and remove valid_flag parameter.
...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); - } - if (valid_flag & LIBNBD_CALLBACK_FREE) { - /* If you need to fre...
2019 Jul 24
6
[PATCH libnbd 0/3] Implement closure lifetimes.
This implements most of what I wrote here: https://www.redhat.com/archives/libguestfs/2019-July/msg00213.html
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 Jul 24
8
[PATCH libnbd v2 0/5] lib: Implement closure lifetimes.
v1 was here: https://www.redhat.com/archives/libguestfs/2019-July/thread.html#00231 The changes address everything that Eric picked up in his review of the first two patches. I have also added two more patches (4 and 5) which respectively fix docs and change int status -> unsigned status, as discussed. Passes make, check, check-valgrind. Rich.
2019 Aug 12
14
[PATCH libnbd 0/7] Add free callbacks and remove valid_flag.
As proposed here: https://www.redhat.com/archives/libguestfs/2019-August/msg00130.html I didn't actually read Eric's replies to that yet because I've been concentrating on writing these patches all day. Anyway here they are and I'll look at what Eric said about the proposal next. Rich.
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