search for: nr_free_callbacks

Displaying 6 results from an estimated 6 matches for "nr_free_callbacks".

Did you mean: do_free_callbacks
2019 Aug 12
0
[PATCH libnbd 1/7] api: Add semi-private function for freeing persistent data.
...nbd_free_callback cb, void *user_data) +{ + int ret = -1; + size_t i; + + if (ptr == NULL) + return 0; + + nbd_internal_set_error_context ("nbd_add_free_callback"); + pthread_mutex_lock (&h->lock); + + /* Extend the list of callbacks in the handle. */ + if (h->nr_free_callbacks >= h->alloc_free_callbacks) { + size_t new_alloc; + struct free_callback *new_callbacks; + + if (h->alloc_free_callbacks == 0) + new_alloc = 8; + else + new_alloc = 2 * h->alloc_free_callbacks; + + new_callbacks = realloc (h->free_callbacks, +...
2019 Aug 12
2
Re: [PATCH libnbd 1/7] api: Add semi-private function for freeing persistent data.
...+ int ret = -1; > + size_t i; > + > + if (ptr == NULL) > + return 0; > + > + nbd_internal_set_error_context ("nbd_add_free_callback"); > + pthread_mutex_lock (&h->lock); > + > + /* Extend the list of callbacks in the handle. */ > + if (h->nr_free_callbacks >= h->alloc_free_callbacks) { > + size_t new_alloc; > + struct free_callback *new_callbacks; > + > + if (h->alloc_free_callbacks == 0) > + new_alloc = 8; > + else > + new_alloc = 2 * h->alloc_free_callbacks; > + > + new_callbacks = rea...
2019 Aug 12
0
Re: [PATCH libnbd 1/7] api: Add semi-private function for freeing persistent data.
...n the count reaches 0, then > things still work. Yes this is another reason why this API is trickier to use than it seems. But this is really necessary if you share a buffer between several AIO calls as I discovered during implementation. > > + */ > > + for (i = 0; i < h->nr_free_callbacks; ++i) { > > + if (ptr <= h->free_callbacks[i].ptr) > > Comparing 2 pointers that are not allocated as part of the same array is > undefined in C. To be safe, you're better off writing this as: > > if ((intptr_t)ptr <= (intptr_t)h->free_callbacks[i].ptr) &g...
2019 Aug 12
2
Re: [PATCH libnbd 1/7] api: Add semi-private function for freeing persistent data.
...ring aio_pread, and then releasing it when retiring that command, really are centered on ref-counting whatever the language handed us, and only free()ing the actual C struct we use to tie everything together under a single pointer. > >>> + */ >>> + for (i = 0; i < h->nr_free_callbacks; ++i) { >>> + if (ptr <= h->free_callbacks[i].ptr) >> >> Comparing 2 pointers that are not allocated as part of the same array is >> undefined in C. To be safe, you're better off writing this as: >> >> if ((intptr_t)ptr <= (intptr_t)h->free...
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 2/7] lib: Allow retired commands to use free_callback on their buffer.
...t (h->cmds_to_issue); - free_cmd_list (h->cmds_in_flight); - free_cmd_list (h->cmds_done); + free_cmd_list (h, h->cmds_to_issue); + free_cmd_list (h, h->cmds_in_flight); + free_cmd_list (h, h->cmds_done); /* Any remaining free callbacks indicate an error. */ if (h->nr_free_callbacks != 0) diff --git a/lib/internal.h b/lib/internal.h index d8b0eed..42e6921 100644 --- a/lib/internal.h +++ b/lib/internal.h @@ -288,7 +288,8 @@ struct command { }; /* aio.c */ -extern void nbd_internal_retire_and_free_command (struct command *); +extern void nbd_internal_retire_and_free_command...