Displaying 20 results from an estimated 2000 matches similar to: "[libnbd PATCH] generator: Prefer closure opaque after function pointer in C"
2019 Jul 16
0
[PATCH libnbd v2] generator: Define new Closure type instead of callbacks.
A Closure is a list of (usually one, but can be more) closures. In C
there is also a singe ‘void *user_data’ parameter which is passed by
the caller into the function and through as the first parameter of
each callback invocation.
By grouping the previously separate Opaque and Callback* parameters
together we can avoid the awkward situation where we have to scan
through the argument list to try
2019 Aug 03
1
[PATCH libnbd] generator: Generate typedefs automatically for Closure arguments.
For example nbd_set_debug takes a callback function. Previously this
was defined explicitly inside the function parameters. This commit
defines a new public typedef:
typedef int (*nbd_debug_callback) (unsigned valid_flag, void *user_data,
const char *context, const char *msg);
and then uses the typedef like this:
extern int nbd_set_debug_callback
2019 Aug 13
0
[PATCH libnbd 1/4] api: Combine callback and user_data into a single struct.
The definition of functions that take a callback is changed so that
the callback and user_data are combined into a single structure, eg:
int64_t nbd_aio_pread (struct nbd_handle *h,
void *buf, size_t count, uint64_t offset,
- int (*completion_callback) (/*..*/), void *user_data,
+ nbd_completion_callback completion_callback,
uint32_t flags);
Several
2019 Jul 24
0
[PATCH libnbd 2/3] lib: Implement closure lifetimes.
Previously closures had a crude flag which tells if they are
persistent or transient. Transient closures (flag = false) last for
the lifetime of the currently called libnbd function. Persistent
closures had an indefinite lifetime which could last for as long as
the handle. In language bindings handling persistent closures was
wasteful as we needed to register a "close callback" to
2019 Jul 24
0
[PATCH libnbd v2 2/5] lib: Implement closure lifetimes.
Previously closures had a crude flag which tells if they are
persistent or transient. Transient closures (flag = false) last for
the lifetime of the currently called libnbd function. Persistent
closures had an indefinite lifetime which could last for as long as
the handle. In language bindings handling persistent closures was
wasteful as we needed to register a "close callback" to
2019 Jul 24
0
[PATCH libnbd 1/3] generator: Change Closure so it describes single callbacks.
In preparation for closure lifetimes, split up the Closure so it no
longer describes a list of closures, but a single callback.
This changes the API because functions which take 2 or more closures
now pass a separate user_data for each one.
---
docs/libnbd.pod | 3 +-
examples/strict-structured-reads.c | 2 +-
generator/generator | 760
2019 Jul 16
1
Re: [PATCH libnbd v2] generator: Define new Closure type instead of callbacks.
On 7/16/19 6:04 AM, Richard W.M. Jones wrote:
> A Closure is a list of (usually one, but can be more) closures. In C
> there is also a singe ‘void *user_data’ parameter which is passed by
> the caller into the function and through as the first parameter of
> each callback invocation.
>
> By grouping the previously separate Opaque and Callback* parameters
> together we can
2019 Jul 25
0
[PATCH libnbd v3 1/2] lib: Implement closure lifetimes.
Previously closures had a crude flag which tells if they are
persistent or transient. Transient closures (flag = false) last for
the lifetime of the currently called libnbd function. Persistent
closures had an indefinite lifetime which could last for as long as
the handle. In language bindings handling persistent closures was
wasteful as we needed to register a "close callback" to
2019 Jul 30
3
[PATCH libnbd] lib: Remove cookie parameter from completion callbacks.
As discussed in this thread, the parameter is an invitation to write
code with race conditions:
https://www.redhat.com/archives/libguestfs/2019-July/thread.html#00309
---
docs/libnbd.pod | 6 +-
examples/glib-main-loop.c | 10 ++--
examples/strict-structured-reads.c | 2 +-
generator/generator | 57
2019 Jun 29
0
[libnbd PATCH 5/6] api: Add new nbd_aio_FOO_notify functions
As mentioned in the previous patch, there are situations where an aio
client wants instant notification when a given command is complete,
rather than having to maintain a separate data structure to track all
in-flight commands and then iterate over that structure to learn which
commands are complete. It's also desirable when writing a server
validation program (such as for checking structured
2019 Jul 16
2
[PATCH libnbd] generator: Swap parameters of nbd_add_close_callback.
The API changes from:
int nbd_add_close_callback (struct nbd_handle *h,
nbd_close_callback cb,
void *user_data);
to:
int nbd_add_close_callback (struct nbd_handle *h,
void *user_data,
nbd_close_callback cb);
The second way is consistent with how other callbacks work
2019 Jul 16
2
[PATCH libnbd] generator: Define new Closure type
** INCOMPLETE **
This is the generator change as discussed on the list already.
The Python and OCaml bindings are not yet done.
It passes all [C only] tests and valgrind.
Note that nbd_add_close_callback is inconsistent with other closure
types because it passes the user_data parameter after the function.
(This is not caused by the current patch, it was already
inconsistent). We decided that
2019 Jul 25
0
[PATCH libnbd v3 2/2] lib: Remove nbd_add_close_callback.
We previously needed nbd_add_close_callback to do cleanup from
language bindings. However now we have closure lifetimes this is no
longer needed and can be removed.
See also:
https://www.redhat.com/archives/libguestfs/2019-July/msg00213.html
---
generator/generator | 18 ------------------
lib/handle.c | 35 -----------------------------------
lib/internal.h | 10 ----------
3 files
2019 Jul 24
0
[PATCH libnbd v2 5/5] lib: Use unsigned for pread_structured status parameter.
This is a bitmask so using an unsigned type is slightly safer. This
is not an ABI change since the types are compatible.
Thanks: Eric Blake.
---
examples/strict-structured-reads.c | 2 +-
generator/generator | 67 ++++++++++++++++--------------
interop/structured-read.c | 2 +-
lib/internal.h | 2 +-
tests/oldstyle.c | 2 +-
5
2019 Aug 13
0
[PATCH libnbd] api: Rename nbd_aio_*_callback to nbd_aio_*.
The original nbd_aio_* (non-callback) functions are removed and
replaced with the renamed callback variants.
This is a simple mechanical change to the API:
(1) Any existing call to nbd_aio_*_callback can simply be renamed to
nbd_aio_*
(2) Any existing call to nbd_aio_* must have two extra NULL parameters
added before the final flags parameter.
In non-C languages, only change (1) is
2020 Sep 07
0
[libnbd PATCH 1/2] generator: Refactor handling of closures in unlocked functions
We have a memory leak when a function with a closure exits early prior
to registering that closure through some path that will guarantee
cleanup. The easiest way to fix it is to guarantee that once a
closure is passed into a public API, it will be cleaned regardless of
whether that API succeeds or fails. But to avoid cleaning the closure
more than once, we need to refactor our internal handling,
2019 Jul 16
2
Re: [PATCH libnbd] generator: Swap parameters of nbd_add_close_callback.
On 7/16/19 10:39 AM, Eric Blake wrote:
> On 7/16/19 10:04 AM, Richard W.M. Jones wrote:
>> The API changes from:
>>
>> int nbd_add_close_callback (struct nbd_handle *h,
>> nbd_close_callback cb,
>> void *user_data);
>>
>> to:
>>
>> int nbd_add_close_callback (struct nbd_handle
2019 Jul 16
0
Re: [PATCH libnbd] generator: Swap parameters of nbd_add_close_callback.
On Tue, Jul 16, 2019 at 11:38:36AM -0500, Eric Blake wrote:
> On 7/16/19 10:39 AM, Eric Blake wrote:
> > On 7/16/19 10:04 AM, Richard W.M. Jones wrote:
> >> The API changes from:
> >>
> >> int nbd_add_close_callback (struct nbd_handle *h,
> >> nbd_close_callback cb,
> >> void
2019 Jul 16
0
Re: [PATCH libnbd] generator: Swap parameters of nbd_add_close_callback.
On 7/16/19 10:04 AM, Richard W.M. Jones wrote:
> The API changes from:
>
> int nbd_add_close_callback (struct nbd_handle *h,
> nbd_close_callback cb,
> void *user_data);
>
> to:
>
> int nbd_add_close_callback (struct nbd_handle *h,
> void *user_data,
>
2019 May 28
0
[libnbd PATCH 2/4] api: Rearrange flags argument to block_status
This is an API/ABI break, but we have not yet declared stable API.
In order to use optional arguments in languages that support that, any
optional arguments must be last. Let's be consistent in this by
rearranging the arguments to block_status so that flags is always
last.
---
generator/generator | 10 ++++++----
interop/dirty-bitmap.c | 6 +++---
lib/rw.c