search for: nbd_internal_free_callback

Displaying 7 results from an estimated 7 matches for "nbd_internal_free_callback".

2019 Aug 12
0
[PATCH libnbd 4/7] lib: Allow closure user_data to be associated with a free callback.
Mechanical change: Wherever we call any closure with the LIBNBD_CALLBACK_FREE function, we also call nbd_internal_free_callback with the closure's user_data. This allows calls to associate a free callback with any closure via its user_data pointer. --- generator/states-reply-simple.c | 1 + generator/states-reply-structured.c | 24 ++++++++++++++++++------ generator/states-reply.c | 1 + generator/sta...
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 12
0
[PATCH libnbd 7/7] api: Remove the valid_flag from all callbacks.
...ffset, LIBNBD_READ_ERROR, &scratch) == -1) if (cmd->error == 0) cmd->error = scratch; - if (valid & LIBNBD_CALLBACK_FREE) { + if (flags & NBD_REPLY_FLAG_DONE) { cmd->cb.fn.chunk = NULL; /* because we've freed it */ nbd_internal_free_callback (h, cmd->cb.fn_user_data); } @@ -402,15 +391,15 @@ valid_flags (struct nbd_handle *h) assert (cmd); /* guaranteed by CHECK */ if (cmd->cb.fn.chunk) { int error = cmd->error; - unsigned valid = valid_flags (h); + uint16_t flags = be16toh (h->sbuf.sr.st...
2019 Aug 12
0
[PATCH libnbd 2/7] lib: Allow retired commands to use free_callback on their buffer.
...h their buffer. If there is one call it. This allows language bindings to use this mechanism to automatically decrement a reference to the persistent buffer (note: this patch does not implement this). The vast majority of this change is simply passing around the handle so we have it when we call nbd_internal_free_callback in lib/aio.c. --- generator/states-reply.c | 2 +- generator/states.c | 2 +- lib/aio.c | 10 ++++++++-- lib/handle.c | 10 +++++----- lib/internal.h | 3 ++- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/generator/states-reply.c b/g...
2019 Aug 12
0
[PATCH libnbd 1/7] api: Add semi-private function for freeing persistent data.
...ptr < cb->ptr) return -1; + else if (ptr > cb->ptr) return 1; + else return 0; +} + +/* Called before the library frees 'ptr', where 'ptr' is something + * that might potentially be associated with a free callback. This is + * called often so must be fast. + */ +void +nbd_internal_free_callback (struct nbd_handle *h, void *ptr) +{ + struct free_callback *free_cb; + + if (ptr == NULL) + return; + + free_cb = bsearch (ptr, h->free_callbacks, h->nr_free_callbacks, + sizeof (struct free_callback), + compare_free_callbacks); + if (free_cb) {...
2019 Aug 12
0
Re: [PATCH libnbd 1/7] api: Add semi-private function for freeing persistent data.
...se return 0; > > +} > > + > > +/* Called before the library frees 'ptr', where 'ptr' is something > > + * that might potentially be associated with a free callback. This is > > + * called often so must be fast. > > + */ > > +void > > +nbd_internal_free_callback (struct nbd_handle *h, void *ptr) > > +{ > > + struct free_callback *free_cb; > > + > > + if (ptr == NULL) > > + return; > > + > > + free_cb = bsearch (ptr, h->free_callbacks, h->nr_free_callbacks, > > + sizeof (struct...
2019 Aug 12
2
Re: [PATCH libnbd 1/7] api: Add semi-private function for freeing persistent data.
...currently work in practice). > + else return 0; > +} > + > +/* Called before the library frees 'ptr', where 'ptr' is something > + * that might potentially be associated with a free callback. This is > + * called often so must be fast. > + */ > +void > +nbd_internal_free_callback (struct nbd_handle *h, void *ptr) > +{ > + struct free_callback *free_cb; > + > + if (ptr == NULL) > + return; > + > + free_cb = bsearch (ptr, h->free_callbacks, h->nr_free_callbacks, > + sizeof (struct free_callback), > +...