search for: may_set_error

Displaying 20 results from an estimated 77 matches for "may_set_error".

2019 Jun 05
0
[PATCH libnbd 1/4] lib: Move nbd_aio_is_* function impls to separate source file.
...ate.c \ nbd-protocol.h \ poll.c \ protocol.c \ diff --git a/lib/aio.c b/lib/aio.c index a129af2..38e0318 100644 --- a/lib/aio.c +++ b/lib/aio.c @@ -48,84 +48,6 @@ nbd_unlocked_aio_notify_write (struct nbd_handle *h) return nbd_internal_run (h, notify_write); } -/* NB: is_locked = false, may_set_error = false. */ -int -nbd_unlocked_aio_is_created (struct nbd_handle *h) -{ - return h->state == STATE_START; -} - -static int -is_connecting_group (enum state_group group) -{ - switch (group) { - case GROUP_TOP: - return 0; - case GROUP_CONNECT: - case GROUP_CONNECT_TCP: - case GROUP_CONNE...
2020 Sep 06
0
[libnbd PATCH 1/3] generator: Introduce REnum/RFlags return types
...enum +| RFlags of flags and closure = { cbname : string; cbargs : cbarg list; @@ -442,7 +444,7 @@ test whether this is the case with L<nbd_supports_tls(3)>."; "get_tls", { default_call with - args = []; ret = RInt; + args = []; ret = REnum (tls_enum); may_set_error = false; shortdesc = "get the TLS request setting"; longdesc = "\ @@ -678,7 +680,7 @@ Future NBD extensions may add further flags. "get_handshake_flags", { default_call with - args = []; ret = RUInt; + args = []; ret = RFlags (handshake_flags);...
2020 Sep 08
2
[libnbd PATCH] python: Plug some memory leaks on error paths
..._mod, \"c_int\", \"i\", *%s);\n" n n n; + pr " Py_DECREF (py_%s_mod);\n" n; pr " if (!py_%s) { PyErr_PrintEx (0); return -1; }\n" n; | CBString _ | CBUInt _ @@ -263,7 +264,7 @@ let print_python_binding name { args; optargs; ret; may_set_error } = pr " PyObject *py_h;\n"; pr " struct nbd_handle *h;\n"; pr " %s ret;\n" (C.type_of_ret ret); - pr " PyObject *py_ret;\n"; + pr " PyObject *py_ret = NULL;\n"; List.iter ( function | Bool n -> pr " int %s;\n&q...
2019 Jul 25
2
[libnbd PATCH] generator: Let nbd_aio_get_direction return unsigned
...* can be called in the START state *) | Connecting (* can be called when connecting/handshaking *) @@ -2013,7 +2014,7 @@ Do not do anything else with the file descriptor."; "aio_get_direction", { default_call with - args = []; ret = RInt; is_locked = false; may_set_error = false; + args = []; ret = RUInt; is_locked = false; may_set_error = false; shortdesc = "return the read or write direction"; longdesc = "\ Return the current direction of this connection, which means @@ -3040,13 +3041,15 @@ let () = (* !may_set_error is incompatib...
2019 Jun 05
0
[PATCH libnbd 2/4] lib: Split nbd_aio_is_* functions into internal.
...o_of_nbd_error (uint32_t error); extern const char *nbd_internal_name_of_nbd_cmd (uint16_t type); diff --git a/lib/is-state.c b/lib/is-state.c index 5ed2ee9..55d103b 100644 --- a/lib/is-state.c +++ b/lib/is-state.c @@ -26,11 +26,12 @@ #include "internal.h" -/* NB: is_locked = false, may_set_error = false. */ -int -nbd_unlocked_aio_is_created (struct nbd_handle *h) +/* Internal functions to test state or groups of states. */ + +bool +nbd_internal_is_state_created (enum state state) { - return h->state == STATE_START; + return state == STATE_START; } static int @@ -51,20 +52,18 @@ i...
2019 Aug 13
0
[PATCH libnbd v2 1/3] generator: Implement OClosure.
...er when we support more optional arguments. - *) - List.iter ( - function - | _, { optargs = [] } | _, { optargs = [OFlags _] } -> () - | (name, _) -> - failwithf "%s: optargs can only be empty list or [OFlags]" name - ) handle_calls; - (* Check functions using may_set_error. *) List.iter ( function @@ -3226,7 +3217,8 @@ let () = | name, { optargs; may_set_error = false } when List.exists (function - | OFlags _ -> true) optargs -> + | OFlags _ -> true + | _ -> false) opt...
2019 Jun 05
9
[PATCH libnbd 0/4] lib: Atomically update h->state.
I need to think about this patch series a bit more, but it does at least pass the tests. Rich.
2019 Aug 10
0
[PATCH libnbd 6/9] generator: Add non-optional Flags type.
...", %s" n + | Flags (n, _) -> pr ", %s" n | Int n -> pr ", %s" n | Int64 n -> pr ", %s" n | SockAddrAndLen (_, len) -> pr ", (int) %s" len @@ -4255,6 +4262,9 @@ let print_python_binding name { args; optargs; ret; may_set_error } = | Closure { cbname } -> pr " PyObject *%s_user_data;\n" cbname | Enum (n, _) -> pr " int %s;\n" n + | Flags (n, _) -> + pr " uint32_t %s_u32;\n" n; + pr " unsigned int %s; /* really uint32_t */\n" n | Int...
2019 Aug 13
0
[PATCH libnbd 5/6] generator: Implement OClosure.
...er when we support more optional arguments. - *) - List.iter ( - function - | _, { optargs = [] } | _, { optargs = [OFlags _] } -> () - | (name, _) -> - failwithf "%s: optargs can only be empty list or [OFlags]" name - ) handle_calls; - (* Check functions using may_set_error. *) List.iter ( function @@ -3377,6 +3368,12 @@ let rec print_arg_list ?(handle = false) ?(types = true) args optargs = if !comma then pr ", "; comma := true; match optarg with + | OClosure { cbname; cbargs } -> + if types then pr "nbd_%s_...
2020 Sep 10
1
[libnbd PATCH] python: Fix more memory leaks
...++- python/utils.c | 11 ++++- 3 files changed, 63 insertions(+), 56 deletions(-) diff --git a/generator/Python.ml b/generator/Python.ml index 9a22f9e..3b86dc0 100644 --- a/generator/Python.ml +++ b/generator/Python.ml @@ -271,7 +271,7 @@ let print_python_binding name { args; optargs; ret; may_set_error } = | BytesIn (n, _) -> pr " Py_buffer %s;\n" n | BytesOut (n, count) -> - pr " char *%s;\n" n; + pr " char *%s = NULL;\n" n; pr " Py_ssize_t %s;\n" count | BytesPersistIn (n, _) | BytesPersistOut (n,...
2019 Aug 09
4
[PATCH libnbd 0/2] generator: Preparatory changes to the generator.
These are some simplifications to the generator. They don't probably make much sense on their own, but they are preparatory to better handling of enums, and or'd lists of flags. Rich.
2019 Aug 09
0
[PATCH libnbd 1/2] generator: Handle closure args (cbargs) specially.
...%s" n - | Mutable arg -> assert false | SockAddrAndLen (_, len) -> pr ", (int) %s" len | Path n | String n -> pr ", %s ? %s : \"NULL\"" n n | StringList n -> () @@ -4007,7 +4031,7 @@ let print_python_binding name { args; ret; may_set_error } = pr "/* Wrapper for %s callback of %s. */\n" cbname name; pr "static int\n"; pr "%s_%s_wrapper " name cbname; - C.print_arg_list ~valid_flag:true ~user_data:true cbargs; + C.print_cbarg_list cbargs; pr "\n";...
2019 Aug 09
0
[PATCH libnbd 2/2] generator: Change handling of Flags to be a true optional argument.
...hen the handle is CLOSED or DEAD *) -let default_call = { args = []; ret = RErr; +let default_call = { args = []; optargs = []; ret = RErr; shortdesc = ""; longdesc = ""; permitted_states = []; is_locked = true; may_set_error = true; @@ -1384,7 +1386,8 @@ Returns the size in bytes of the NBD export." "pread", { default_call with - args = [ BytesOut ("buf", "count"); UInt64 "offset"; Flags "flags" ]; + args = [ BytesOut ("buf", "count&q...
2019 Jun 05
1
[PATCH libnbd v2] lib: Atomically update h->state when leaving the locked region.
...hexdump (const void *data, size_t len, FILE *fp); diff --git a/lib/is-state.c b/lib/is-state.c index c941ab4..b2c20df 100644 --- a/lib/is-state.c +++ b/lib/is-state.c @@ -98,44 +98,48 @@ nbd_internal_is_state_closed (enum state state) return state == STATE_CLOSED; } -/* NB: is_locked = false, may_set_error = false. */ +/* The nbd_unlocked_aio_is_* calls are the public APIs + * for reading the state of the handle. + * + * They all have: is_locked = false, may_set_error = false. + * + * They all read the public state, not the real state. Therefore you + * SHOULD NOT call these functions from elsewhere...
2019 Jun 08
0
[PATCH libnbd v3] lib: Atomically update h->state when leaving the locked region.
...pr " {\n"; List.iter ( fun ({ comment; parsed = { display_name; state_enum } }) -> @@ -2842,6 +2843,33 @@ let permitted_state_text permitted_states = let generate_lib_api_c () = let print_wrapper (name, {args; ret; permitted_states; is_locked; may_set_error}) = + if permitted_states <> [] then ( + pr "static inline bool\n"; + pr "%s_in_permitted_state (struct nbd_handle *h)\n" name; + pr "{\n"; + pr " const enum state state = get_public_state (h);\n"; + pr "\n"; +...
2019 Jun 05
1
[libnbd PATCH] api: Add nbd_supports_tls
...with C<nbd_supports_tls>."; }; "aio_connect_unix", { @@ -1876,6 +1898,15 @@ The release number is incremented for each release along a particular branch."; }; + "supports_tls", { + default_call with + args = []; ret = RBool; is_locked = false; may_set_error = false; + shortdesc = "return true if libnbd was compiled with support for TLS"; + longdesc = "\ +Returns true if libnbd was compiled with gnutls which is required +to support TLS encryption, or false if not. See C<nbd_set_tls>."; + }; + "supports_uri&quot...
2019 Oct 04
0
[PATCH libnbd 3/4] api: Add nbd_connect_socket.
...-> pr ", %s" n | Int64 n -> pr ", %s" n | SockAddrAndLen (_, len) -> pr ", (int) %s" len | Path n | String n -> pr ", %s ? %s : \"NULL\"" n n @@ -4889,7 +4927,7 @@ let print_python_binding name { args; optargs; ret; may_set_error } = | Flags (n, _) -> pr " uint32_t %s_u32;\n" n; pr " unsigned int %s; /* really uint32_t */\n" n - | Int n -> pr " int %s;\n" n + | Fd n | Int n -> pr " int %s;\n" n | Int64 n -> pr " int64_t %s_...
2019 Aug 10
0
[PATCH libnbd 3/9] generator: Add Enum type for enumerated types / unions.
...{ cbname } -> () + | Enum (n, _) -> pr ", %s" n | Int n -> pr ", %s" n | Int64 n -> pr ", %s" n | SockAddrAndLen (_, len) -> pr ", (int) %s" len @@ -4206,6 +4237,7 @@ let print_python_binding name { args; optargs; ret; may_set_error } = pr " struct py_aio_buffer *%s_buf;\n" n | Closure { cbname } -> pr " PyObject *%s_user_data;\n" cbname + | Enum (n, _) -> pr " int %s;\n" n | Int n -> pr " int %s;\n" n | Int64 n -> pr " int6...
2020 Sep 29
2
[PATCH libnbd] generator: Add SizeT type, maps to C size_t.
...Int64 _ | Path _ + | SizeT _ | String _ | SockAddrAndLen _ | UInt _ diff --git a/generator/Python.ml b/generator/Python.ml index 1705ad9..46b5828 100644 --- a/generator/Python.ml +++ b/generator/Python.ml @@ -295,6 +295,8 @@ let print_python_binding name { args; optargs; ret; may_set_error } = | Path n -> pr " PyObject *py_%s = NULL;\n" n; pr " char *%s = NULL;\n" n + | SizeT n -> + pr " Py_ssize_t %s;\n" n | SockAddrAndLen (n, _) -> pr " /* XXX Complicated - Python uses a tuple of different\n&...
2019 Aug 31
1
[PATCH libnbd] Add bindings for Rust language
Still not working, but I took the latest patch and: - rebased it against libnbd 1.0 - fixed it so it handles new args and cbargs The generator now runs without warnings. This patch doesn't handle optargs at all. In C these are converted to non-optional parameter. Rust doesn't (AFAIK) have optional or labelled arguments unfortunately. Rich.