search for: debug_data

Displaying 20 results from an estimated 25 matches for "debug_data".

2019 Aug 13
0
[PATCH libnbd v2 3/3] api: Add nbd_clear_debug_callback.
...ebug.c +++ b/lib/debug.c @@ -38,13 +38,24 @@ nbd_unlocked_get_debug (struct nbd_handle *h) return h->debug; } +int +nbd_unlocked_clear_debug_callback (struct nbd_handle *h) +{ + if (h->debug_callback) + /* ignore return value */ + h->debug_callback (LIBNBD_CALLBACK_FREE, h->debug_data, NULL, NULL); + h->debug_callback = NULL; + h->debug_data = NULL; + return 0; +} + int nbd_unlocked_set_debug_callback (struct nbd_handle *h, nbd_debug_callback debug_callback, void *data) { - if (h->debug_callback) - /* ignore return value */ -...
2019 Aug 12
0
[PATCH libnbd 4/7] lib: Allow closure user_data to be associated with a free callback.
...+42,11 @@ int nbd_unlocked_set_debug_callback (struct nbd_handle *h, nbd_debug_callback debug_callback, void *data) { - if (h->debug_callback) + if (h->debug_callback) { /* ignore return value */ h->debug_callback (LIBNBD_CALLBACK_FREE, h->debug_data, NULL, NULL); + nbd_internal_free_callback (h, h->debug_data); + } h->debug_callback = debug_callback; h->debug_data = data; return 0; diff --git a/lib/handle.c b/lib/handle.c index 0f50e38..5a47bd8 100644 --- a/lib/handle.c +++ b/lib/handle.c @@ -113,8 +113,10 @@ nbd_close (s...
2019 Aug 13
1
Re: [PATCH libnbd v2 3/3] api: Add nbd_clear_debug_callback.
...nbd_unlocked_get_debug (struct nbd_handle *h) > return h->debug; > } > > +int > +nbd_unlocked_clear_debug_callback (struct nbd_handle *h) > +{ > + if (h->debug_callback) > + /* ignore return value */ > + h->debug_callback (LIBNBD_CALLBACK_FREE, h->debug_data, NULL, NULL); > + h->debug_callback = NULL; > + h->debug_data = NULL; > + return 0; > +} Is it worth returning -1 if no callback was associated, and/or forwarding the return value of callback(FREE, ptr) as the return value of this function? (That's more complicated; I'...
2019 Jul 24
1
Re: [PATCH libnbd v2 2/5] lib: Implement closure lifetimes.
...nt (*debug_fn) (void *, const char *, const char *), > - void *data) > + debug_fn debug_fn, void *data) > { > + if (h->debug_fn) > + /* ignore return value */ > + h->debug_fn (LIBNBD_CALLBACK_FREE, h->debug_data, NULL, NULL); Is it worth outputting a debug message just before freeing things? Or put differently, should this be something like h->debug_fn (LIBNBD_CALLBACK_VALID | LIBNBD_CALLBACK_FREE, h->debug_data, context, "changing debug callback"); Also, should nbd_close()...
2019 Aug 03
1
[PATCH libnbd] generator: Generate typedefs automatically for Closure arguments.
...uct nbd_handle *h, - debug_fn debug_fn, void *data) + nbd_debug_callback debug_callback, void *data) { - if (h->debug_fn) + if (h->debug_callback) /* ignore return value */ - h->debug_fn (LIBNBD_CALLBACK_FREE, h->debug_data, NULL, NULL); - h->debug_fn = debug_fn; + h->debug_callback (LIBNBD_CALLBACK_FREE, h->debug_data, NULL, NULL); + h->debug_callback = debug_callback; h->debug_data = data; return 0; } @@ -76,9 +76,9 @@ nbd_internal_debug (struct nbd_handle *h, const char *fs, ...) if (r...
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 Jun 04
0
[PATCH libnbd v2 2/4] generator: Callback returns int instead of void.
...ug_callback (struct nbd_handle *h, void *data, - void (*debug_fn) (void *, const char *, const char *)) + int (*debug_fn) (void *, const char *, const char *)) { h->debug_fn = debug_fn; h->debug_data = data; @@ -75,6 +75,7 @@ nbd_internal_debug (struct nbd_handle *h, const char *fs, ...) goto out; if (h->debug_fn) + /* ignore return value */ h->debug_fn (h->debug_data, context, msg); else fprintf (stderr, "libnbd: debug: %s: %s\n", context ? : "...
2019 Aug 12
0
[PATCH libnbd 7/7] api: Remove the valid_flag from all callbacks.
...c +++ b/lib/debug.c @@ -42,11 +42,8 @@ int nbd_unlocked_set_debug_callback (struct nbd_handle *h, nbd_debug_callback debug_callback, void *data) { - if (h->debug_callback) { - /* ignore return value */ - h->debug_callback (LIBNBD_CALLBACK_FREE, h->debug_data, NULL, NULL); + if (h->debug_callback) nbd_internal_free_callback (h, h->debug_data); - } h->debug_callback = debug_callback; h->debug_data = data; return 0; @@ -80,7 +77,7 @@ nbd_internal_debug (struct nbd_handle *h, const char *fs, ...) if (h->debug_callback)...
2019 Jul 25
0
[PATCH libnbd v3 2/2] lib: Remove nbd_add_close_callback.
...@@ -90,7 +90,6 @@ nbd_create (void) void nbd_close (struct nbd_handle *h) { - struct close_callback *cc, *cc_next; struct meta_context *m, *m_next; if (h == NULL) @@ -100,12 +99,6 @@ nbd_close (struct nbd_handle *h) if (h->debug_fn) h->debug_fn (LIBNBD_CALLBACK_FREE, h->debug_data, NULL, NULL); - for (cc = h->close_callbacks; cc != NULL; cc = cc_next) { - cc_next = cc->next; - cc->cb (cc->user_data); - free (cc); - } - free (h->bs_entries); for (m = h->meta_contexts; m != NULL; m = m_next) { m_next = m->next; @@ -202,34 +195,6 @@...
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 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 16
1
[libnbd PATCH] generator: Prefer closure opaque after function pointer in C
...void *data, - int (*debug_fn) (void *, const char *, const char *)) + int (*debug_fn) (void *, const char *, const char *), + void *data) { h->debug_fn = debug_fn; h->debug_data = data; diff --git a/lib/handle.c b/lib/handle.c index 00d0ac2..5003227 100644 --- a/lib/handle.c +++ b/lib/handle.c @@ -203,7 +203,7 @@ nbd_unlocked_add_meta_context (struct nbd_handle *h, const char *name) */ int nbd_add_close_callback (struct nbd_handle *h, - void *use...
2019 Jul 24
0
[PATCH libnbd 2/3] lib: Implement closure lifetimes.
...int (*debug_fn) (void *, const char *, const char *), + int (*debug_fn) (int, void *, const char *, const char *), void *data) { + if (h->debug_fn) + /* ignore return value */ + h->debug_fn (LIBNBD_CALLBACK_FREE, h->debug_data, NULL, NULL); h->debug_fn = debug_fn; h->debug_data = data; return 0; @@ -76,7 +79,7 @@ nbd_internal_debug (struct nbd_handle *h, const char *fs, ...) if (h->debug_fn) /* ignore return value */ - h->debug_fn (h->debug_data, context, msg); + h->debug_fn (LI...
2019 Jul 25
0
[PATCH libnbd v3 1/2] lib: Implement closure lifetimes.
...int (*debug_fn) (void *, const char *, const char *), - void *data) + debug_fn debug_fn, void *data) { + if (h->debug_fn) + /* ignore return value */ + h->debug_fn (LIBNBD_CALLBACK_FREE, h->debug_data, NULL, NULL); h->debug_fn = debug_fn; h->debug_data = data; return 0; @@ -76,7 +78,7 @@ nbd_internal_debug (struct nbd_handle *h, const char *fs, ...) if (h->debug_fn) /* ignore return value */ - h->debug_fn (h->debug_data, context, msg); + h->debug_fn (LI...
2019 Jul 24
0
[PATCH libnbd v2 2/5] lib: Implement closure lifetimes.
...int (*debug_fn) (void *, const char *, const char *), - void *data) + debug_fn debug_fn, void *data) { + if (h->debug_fn) + /* ignore return value */ + h->debug_fn (LIBNBD_CALLBACK_FREE, h->debug_data, NULL, NULL); h->debug_fn = debug_fn; h->debug_data = data; return 0; @@ -76,7 +78,7 @@ nbd_internal_debug (struct nbd_handle *h, const char *fs, ...) if (h->debug_fn) /* ignore return value */ - h->debug_fn (h->debug_data, context, msg); + h->debug_fn (LI...
2019 Aug 13
0
[PATCH libnbd 1/4] api: Combine callback and user_data into a single struct.
...b/lib/debug.c @@ -41,23 +41,22 @@ nbd_unlocked_get_debug (struct nbd_handle *h) int nbd_unlocked_clear_debug_callback (struct nbd_handle *h) { - if (h->debug_callback) + if (h->debug_callback.callback) /* ignore return value */ - h->debug_callback (LIBNBD_CALLBACK_FREE, h->debug_data, NULL, NULL); - h->debug_callback = NULL; - h->debug_data = NULL; + h->debug_callback.callback (LIBNBD_CALLBACK_FREE, + h->debug_callback.user_data, NULL, NULL); + h->debug_callback.callback = NULL; return 0; } int nbd_unlocked_set_debug_c...
2019 Jul 24
2
Re: [PATCH libnbd 2/3] lib: Implement closure lifetimes.
...t char *, const char *), > + int (*debug_fn) (int, void *, const char *, const char *), > void *data) > { > + if (h->debug_fn) > + /* ignore return value */ > + h->debug_fn (LIBNBD_CALLBACK_FREE, h->debug_data, NULL, NULL); This frees the first debug callback when installing a second; but where does nbd_close free the second? Also, do we allow C code to pass NULL to uninstall a handler? Should other languages be able to clear out a callback? -- Eric Blake, Principal Software Engineer Red Hat, Inc....
2019 Jul 24
0
Re: [PATCH libnbd 2/3] lib: Implement closure lifetimes.
...> + int (*debug_fn) (int, void *, const char *, const char *), > > void *data) > > { > > + if (h->debug_fn) > > + /* ignore return value */ > > + h->debug_fn (LIBNBD_CALLBACK_FREE, h->debug_data, NULL, NULL); > > This frees the first debug callback when installing a second; but where > does nbd_close free the second? Also, do we allow C code to pass NULL > to uninstall a handler? Should other languages be able to clear out a > callback? Yes nbd_close should check and call...
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 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