Displaying 20 results from an estimated 1000 matches similar to: "[libnbd PATCH] python: Fix more memory leaks"
2020 Sep 08
2
[libnbd PATCH] python: Plug some memory leaks on error paths
Inspection of the generated code showed several places where we did
not release references on all error paths. In particular, switching
things to always jump to an out: label, even when the underlying C
function cannot fail, makes it easier to clean up when the user passes
wrong types to a function call.
One of the easiest triggers without this patch was this one-liner:
$ nbdsh -c
2020 Sep 11
0
[libnbd PATCH v2 2/5] generator: Refactor filtering of accepted OFlags
Rather than having to open-code the list of accepted command flags in
the unlocked version of each command, we can store that information in
the generator to produce the check directly in the public API.
---
generator/API.ml | 53 +++++++++++++++++++++++++++++----------------
generator/API.mli | 3 ++-
generator/C.ml | 26 +++++++++++++++-------
generator/GoLang.ml | 10 ++++-----
2019 Aug 13
0
[PATCH libnbd v2 1/3] generator: Implement OClosure.
An optional Closure parameter, but otherwise works the same way as
Closure.
---
generator/generator | 57 ++++++++++++++++++++++++++++++++++++---------
1 file changed, 46 insertions(+), 11 deletions(-)
diff --git a/generator/generator b/generator/generator
index 8cf95b6..8f15786 100755
--- a/generator/generator
+++ b/generator/generator
@@ -867,6 +867,7 @@ and arg =
| UInt32 of string
2019 Aug 13
0
[PATCH libnbd 5/6] generator: Implement OClosure.
An optional Closure parameter, but otherwise works the same way as
Closure.
---
generator/generator | 54 ++++++++++++++++++++++++++++++++++++---------
1 file changed, 44 insertions(+), 10 deletions(-)
diff --git a/generator/generator b/generator/generator
index 01da1c3..3add9a4 100755
--- a/generator/generator
+++ b/generator/generator
@@ -867,6 +867,7 @@ and arg =
| UInt32 of string
2019 Aug 10
0
[PATCH libnbd 6/9] generator: Add non-optional Flags type.
This works just like OFlags but is a non-optional argument.
---
generator/generator | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/generator/generator b/generator/generator
index 2b37cea..96d1148 100755
--- a/generator/generator
+++ b/generator/generator
@@ -856,6 +856,7 @@ and arg =
| BytesPersistOut of string * string
| Closure of closure (* function pointer
2019 Oct 04
0
[PATCH libnbd 3/4] api: Add nbd_connect_socket.
This allows us to connect directly to a connected socket. How exactly
the socket is created and connected to the NBD server is left up to
the main program.
The only real complexity in this patch is allowing file descriptors to
be passed to libnbd APIs. Luckily in C and Python we can treat them
exactly as integers, and in OCaml they are also integers but with a
different type.
---
2019 Aug 14
0
[PATCH libnbd 2/2] ocaml: Remove NBD.Buffer.free function, use the completion callback instead.
By using the completion free callback function we don't need to
manually free the buffer.
Note that after this patch OClosures are always called from OCaml,
because we might need the side effect of freeing the buffer.
This reverts part of commit fef1c281a65d061127bf178e5f8cfca0a2475c56.
---
generator/generator | 59 +++++++++++++++++++++-----------
ocaml/buffer.c
2019 Aug 13
1
Re: [PATCH libnbd v2 1/3] generator: Implement OClosure.
On 8/13/19 10:12 AM, Richard W.M. Jones wrote:
> An optional Closure parameter, but otherwise works the same way as
> Closure.
> ---
> generator/generator | 57 ++++++++++++++++++++++++++++++++++++---------
> 1 file changed, 46 insertions(+), 11 deletions(-)
>
> @@ -4394,6 +4399,16 @@ let print_python_binding name { args; optargs; ret; may_set_error } =
> ) args;
>
2019 Aug 13
2
Re: [PATCH libnbd 5/6] generator: Implement OClosure.
On 8/13/19 5:06 AM, Richard W.M. Jones wrote:
> An optional Closure parameter, but otherwise works the same way as
> Closure.
> @@ -3778,6 +3777,7 @@ let generate_lib_api_c () =
> ) args;
> List.iter (
> function
> + | OClosure { cbname } -> pr ", %s_callback ? \"<fun>\" : \"NULL\"" cbname
Well, it also permits a
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 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 Aug 09
0
[PATCH libnbd 2/2] generator: Change handling of Flags to be a true optional argument.
In libguestfs generator we have the concept of optargs which is
different from plain arguments. These are mapped to optional
arguments in languages that support them such as Python.
This commit adds a new concept of optargs. At the moment it is simply
limited to handling the optional (in some bindings) flags parameter
which is used to handle the NBD_CMD_FLAG_* flags.
If present, the old Flags
2019 Aug 10
0
[PATCH libnbd 3/9] generator: Add Enum type for enumerated types / unions.
Previously nbd_set_tls had an integer argument which was 0 for
disable, 1 for allow and 2 for require. This commit adds a proper
enumerated type to describe this, defining LIBNBD_TLS_DISABLE = 0,
LIBNBD_TLS_ALLOW = 1 and LIBNBD_TLS_REQUIRE = 2. (Note the C API
doesn't change).
In C the enumerated type is still defined and passed as an int (not as
an enum). While we could define an enum
2019 Aug 09
0
[PATCH libnbd 1/2] generator: Handle closure args (cbargs) specially.
If we accept that callbacks will never handle the full range of
parameters then we can simplify the generator quite a bit by using a
special type for closure args vs normal method args.
This removes many asserts and quite a bit of unreachable code
(eg. Python code for handling ArrayAndLen in normal methods that was
never used).
The output of the generator after this commit should be identical.
2019 Aug 13
0
[PATCH libnbd 2/6] generator: Create only one Python wrapper per closure.
We were previously generating one instance of the Python closure
wrapper per (function * Closure arg). However these wrappers didn't
actually differ across functions. We can therefore save a lot of code
by only generating one wrapper per closure globally.
This reduces the amount of generated code by nearly 25%. Before and
after:
$ wc -l python/methods.c
3275 python/methods.c
$ wc -l
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 Aug 14
0
[PATCH libnbd 2/3] python: Hold a refcount to persistent AIO buffer until command completion.
---
generator/generator | 31 ++++++++++++++++++++++++++++---
1 file changed, 28 insertions(+), 3 deletions(-)
diff --git a/generator/generator b/generator/generator
index f6a4856..9bcb08d 100755
--- a/generator/generator
+++ b/generator/generator
@@ -3982,6 +3982,13 @@ let print_python_closure_wrapper { cbname; cbargs } =
pr " const struct user_data *data = user_data;\n";
pr
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 13
0
Re: [PATCH libnbd 5/6] generator: Implement OClosure.
On Tue, Aug 13, 2019 at 06:34:11AM -0500, Eric Blake wrote:
> On 8/13/19 5:06 AM, Richard W.M. Jones wrote:
> > An optional Closure parameter, but otherwise works the same way as
> > Closure.
>
> > @@ -3778,6 +3777,7 @@ let generate_lib_api_c () =
> > ) args;
> > List.iter (
> > function
> > + | OClosure { cbname } -> pr
2020 Sep 29
2
[PATCH libnbd] generator: Add SizeT type, maps to C size_t.
---
generator/API.ml | 1 +
generator/API.mli | 1 +
generator/C.ml | 14 ++++++++++----
generator/GoLang.ml | 5 +++++
generator/OCaml.ml | 5 +++++
generator/Python.ml | 11 +++++++++--
6 files changed, 31 insertions(+), 6 deletions(-)
diff --git a/generator/API.ml b/generator/API.ml
index 0a876c4..b93580d 100644
--- a/generator/API.ml
+++ b/generator/API.ml
@@ -47,6 +47,7 @@