search for: threadlocal_set_error

Displaying 20 results from an estimated 36 matches for "threadlocal_set_error".

Did you mean: threadlocal_get_error
2020 Mar 25
2
Re: nbdkit / mingw support
..._*, nbdkit_realpath, > nbdkit_debug, nbdkit_error, nbdkit_*extents). > > Unfortunately some functions depend themselves on internals > of the server: > > * nbdkit_nanosleep, nbdkit_export_name, nbdkit_peer_name call > threadlocal_get_conn > * nbdkit_set_error calls threadlocal_set_error > * nbdkit_shutdown must set the quit global (or call a server function) Yeah, there's some awkward dependencies to figure out. It's obvious the library has to export public nbdkit_* interfaces for the sake of plugins, but can it also export one additional symbol _nbdkit_init() for...
2020 Mar 24
2
Re: nbdkit / mingw support
On 3/24/20 3:12 PM, Eric Blake wrote: >> (For non-mingw platforms) this breaks the source API promises rather >> seriously, so if I understand your proposal correctly I don't think >> this is a good idea.  It's possibly something we can consider for >> internal plugins, or for the V3 API. > > How does it break API to request that someone link against a
2020 Mar 25
0
Re: nbdkit / mingw support
...dkit_debug, nbdkit_error, nbdkit_*extents). > > > >Unfortunately some functions depend themselves on internals > >of the server: > > > > * nbdkit_nanosleep, nbdkit_export_name, nbdkit_peer_name call > > threadlocal_get_conn > > * nbdkit_set_error calls threadlocal_set_error > > * nbdkit_shutdown must set the quit global (or call a server function) > > Yeah, there's some awkward dependencies to figure out. It's obvious > the library has to export public nbdkit_* interfaces for the sake of > plugins, but can it also export one additional symb...
2019 May 09
1
[nbdkit PATCH] plugins: Use static buffer for plugin_zeroes
...nst char buf[MAX_REQUEST_SIZE]; uint32_t limit; int r = -1; bool may_trim = flags & NBDKIT_FLAG_MAY_TRIM; @@ -639,12 +639,7 @@ plugin_zero (struct backend *b, struct connection *conn, assert (p->plugin.pwrite || p->plugin._pwrite_old); flags &= ~NBDKIT_FLAG_MAY_TRIM; threadlocal_set_error (0); - limit = count < MAX_REQUEST_SIZE ? count : MAX_REQUEST_SIZE; - buf = calloc (limit, 1); - if (!buf) { - *err = ENOMEM; - return -1; - } + limit = count < sizeof (buf) ? count : sizeof (buf); while (count) { r = plugin_pwrite (b, conn, buf, limit, offset, flags, err)...
2020 Mar 25
0
Re: nbdkit / mingw support
...obviously self-contained (eg. nbdkit_parse_*, nbdkit_realpath, nbdkit_debug, nbdkit_error, nbdkit_*extents). Unfortunately some functions depend themselves on internals of the server: * nbdkit_nanosleep, nbdkit_export_name, nbdkit_peer_name call threadlocal_get_conn * nbdkit_set_error calls threadlocal_set_error * nbdkit_shutdown must set the quit global (or call a server function) I guess we can deal with the first ones by moving threadlocal.c into the same library, although it's a bit awkward. The quit flag is still more awkward because you have to move a lot of quit pipe handling code into the li...
2019 Sep 18
1
[PATCH nbdkit] server: Remove useless thread local sockaddr.
...um (size_t instance_num); extern size_t threadlocal_get_instance_num (void); -extern void threadlocal_set_sockaddr (const struct sockaddr *addr, - socklen_t addrlen) - __attribute__((__nonnull__ (1))); -/*extern void threadlocal_get_sockaddr ();*/ extern void threadlocal_set_error (int err); extern int threadlocal_get_error (void); extern void *threadlocal_buffer (size_t size); diff --git a/server/sockets.c b/server/sockets.c index dfaa3ea..3514c69 100644 --- a/server/sockets.c +++ b/server/sockets.c @@ -260,8 +260,6 @@ free_listening_sockets (int *socks, size_t nr_socks)...
2019 Apr 23
0
[PATCH nbdkit v2 2/2] server: Use a thread-local pread/pwrite buffer to avoid leaking heap data.
...ions(+), 7 deletions(-) diff --git a/server/internal.h b/server/internal.h index 837cd4a..817f022 100644 --- a/server/internal.h +++ b/server/internal.h @@ -350,6 +350,7 @@ extern void threadlocal_set_sockaddr (const struct sockaddr *addr, /*extern void threadlocal_get_sockaddr ();*/ extern void threadlocal_set_error (int err); extern int threadlocal_get_error (void); +extern void *threadlocal_buffer (size_t size); /* Declare program_name. */ #if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME == 1 diff --git a/server/protocol.c b/server/protocol.c index 3f89f6d..9e8eea5 100644 --- a/server/protocol.c +++ b/server...
2018 Feb 01
2
Re: [nbdkit PATCH v2 1/3] backend: Rework internal/filter error return semantics
...flags & NBD_CMD_FLAG_FUA); > > - /* The plugin should call nbdkit_set_error() to request a particular > - error, otherwise we fallback to errno or EIO. */ > + /* Clear the error, so that we know if the plugin calls > + nbdkit_set_error() or relied on errno. */ > threadlocal_set_error (0); > > switch (cmd) { > case NBD_CMD_READ: > - if (backend->pread (backend, conn, buf, count, offset, 0) == -1) > - return get_error (conn); > - break; > + return backend->pread (backend, conn, buf, count, offset, 0); ... > - default: > -...
2020 Aug 06
2
[PATCH nbdkit] Experiment with parallel python plugin
...mulate = false; bool need_flush = false; + void *zero_buffer = NULL; + int buffer_size = MIN (MAX_REQUEST_SIZE, count); if (fua && backend_can_fua (b) != NBDKIT_FUA_NATIVE) { flags &= ~NBDKIT_FLAG_FUA; @@ -669,19 +671,25 @@ plugin_zero (struct backend *b, void *handle, threadlocal_set_error (0); *err = 0; + *err = posix_memalign(&zero_buffer, 4096, buffer_size); + if (*err != 0) { + r = -1; + goto done; + } + + memset(zero_buffer, 0, buffer_size); + while (count) { - /* Always contains zeroes, but we can't use const or else gcc 9 - * will use .roda...
2020 Mar 26
0
[PATCH nbdkit 5/9 patch split 5/5] server: Indirect slow path, non-self-contained functions through the server.
...--git a/server/plugins.c b/server/plugins.c index fa572a6a..444ba63e 100644 --- a/server/plugins.c +++ b/server/plugins.c @@ -460,7 +460,7 @@ plugin_can_cache (struct backend *b, void *handle) * where !errno_is_preserved. */ void -nbdkit_set_error (int err) +do_nbdkit_set_error (int err) { threadlocal_set_error (err); } diff --git a/server/public.c b/server/public.c index 33d40688..56302bb4 100644 --- a/server/public.c +++ b/server/public.c @@ -30,34 +30,21 @@ * SUCH DAMAGE. */ -/* This file contains the public utility APIs to be exported by nbdkit - * for use by filters and plugins, declared in nb...
2020 Aug 06
0
[PATCH nbdkit] Experiment with parallel python plugin
...mulate = false; bool need_flush = false; + void *zero_buffer = NULL; + int buffer_size = MIN (MAX_REQUEST_SIZE, count); if (fua && backend_can_fua (b) != NBDKIT_FUA_NATIVE) { flags &= ~NBDKIT_FLAG_FUA; @@ -669,19 +671,25 @@ plugin_zero (struct backend *b, void *handle, threadlocal_set_error (0); *err = 0; + *err = posix_memalign(&zero_buffer, 4096, buffer_size); + if (*err != 0) { + r = -1; + goto done; + } + + memset(zero_buffer, 0, buffer_size); + while (count) { - /* Always contains zeroes, but we can't use const or else gcc 9 - * will use .roda...
2018 Feb 01
0
[nbdkit PATCH v2 1/3] backend: Rework internal/filter error return semantics
...onn->can_flush && (flags & NBD_CMD_FLAG_FUA); - /* The plugin should call nbdkit_set_error() to request a particular - error, otherwise we fallback to errno or EIO. */ + /* Clear the error, so that we know if the plugin calls + nbdkit_set_error() or relied on errno. */ threadlocal_set_error (0); switch (cmd) { case NBD_CMD_READ: - if (backend->pread (backend, conn, buf, count, offset, 0) == -1) - return get_error (conn); - break; + return backend->pread (backend, conn, buf, count, offset, 0); case NBD_CMD_WRITE: if (fua) f |= NBDKIT_FLAG_FUA;...
2020 Aug 06
0
Re: [PATCH nbdkit] Experiment with parallel python plugin
...= false; > + void *zero_buffer = NULL; > + int buffer_size = MIN (MAX_REQUEST_SIZE, count); > > if (fua && backend_can_fua (b) != NBDKIT_FUA_NATIVE) { > flags &= ~NBDKIT_FLAG_FUA; > @@ -669,19 +671,25 @@ plugin_zero (struct backend *b, void *handle, > threadlocal_set_error (0); > *err = 0; > > + *err = posix_memalign(&zero_buffer, 4096, buffer_size); > + if (*err != 0) { > + r = -1; > + goto done; > + } > + > + memset(zero_buffer, 0, buffer_size); > + > while (count) { > - /* Always contains zeroes, but...
2017 Nov 14
7
[PATCH 0/3] Alternate way to avoid race conditions when nbdkit exits.
This fixes the race conditions for me, using the test described here: https://www.redhat.com/archives/libguestfs/2017-September/msg00226.html Rich.
2019 Aug 23
1
[nbdkit PATCH 1/3] server: Add internal support for NBDKIT_FLAG_FAST_ZERO
...set, @@ -658,6 +673,12 @@ plugin_zero (struct backend *b, struct connection *conn, goto done; } + if (fast_zero) { + assert (r == -1); + *err = EOPNOTSUPP; + goto done; + } + assert (p->plugin.pwrite || p->plugin._pwrite_old); flags &= ~NBDKIT_FLAG_MAY_TRIM; threadlocal_set_error (0); @@ -762,6 +783,7 @@ static struct backend plugin_functions = { .is_rotational = plugin_is_rotational, .can_trim = plugin_can_trim, .can_zero = plugin_can_zero, + .can_fast_zero = plugin_can_fast_zero, .can_extents = plugin_can_extents, .can_fua = plugin_can_fua, .can_multi_c...
2019 Apr 23
4
[PATCH nbdkit v2 0/2] Be careful not to leak server heap memory to the client.
Version 1 was here: https://www.redhat.com/archives/libguestfs/2019-April/msg00144.html Version 2 makes a couple of much larger changes: The OCaml patch changes the API of the pread method so it matches what other language bindings are already doing, ie. get the language plugin to return a newly allocated buffer, check it is long enough, copy out the data. The server patch implements a
2019 Jan 02
0
[PATCH nbdkit v2 1/2] Annotate internal function parameters with attribute((nonnull)).
...r, socklen_t addrlen); +extern void threadlocal_set_sockaddr (const struct sockaddr *addr, + socklen_t addrlen) + __attribute__((__nonnull__ (1))); extern const char *threadlocal_get_name (void); extern size_t threadlocal_get_instance_num (void); extern void threadlocal_set_error (int err); diff --git a/tests/test.h b/tests/test.h index dae3afc..cf0b1eb 100644 --- a/tests/test.h +++ b/tests/test.h @@ -44,7 +44,8 @@ extern const char *sock; /* socket of most recent nbdkit process */ extern const char *server[2]; /* server parameter for add_drive */ /* Can be cal...
2018 Jan 28
3
[nbdkit PATCH 0/2] RFC: tweak error handling, add log filter
Here's what I'm currently playing with; I'm not ready to commit anything until I rebase my FUA work on top of this, as I only want to break filter ABI once between releases. Eric Blake (2): backend: Rework internal/filter error return semantics filters: Add log filter TODO | 2 - docs/nbdkit-filter.pod | 84 +++++++-- docs/nbdkit.pod
2019 Aug 03
5
[nbdkit PATCH 0/3] More responsive shutdown
We noticed while writing various libnbd tests that when the delay filter is in use, there are scenarios where we had to resort to SIGKILL to get rid of nbdkit, because it was non-responsive to SIGINT. I'm still trying to figure out the best way to add testsuite coverage of this, but already proved to myself that it works from the command line, under two scenarios that both used to cause long
2018 Mar 08
0
[nbdkit PATCH v3 11/15] plugins: Expose new FUA callbacks
...may_trim); + else + emulate = true; + if (r == -1) + *err = emulate ? EOPNOTSUPP : get_error (p); + if (r == 0 || *err != EOPNOTSUPP) + goto done; - assert (p->plugin.pwrite); + assert (p->plugin.pwrite || p->plugin._pwrite_old); + flags &= ~NBDKIT_FLAG_MAY_TRIM; threadlocal_set_error (0); limit = count < MAX_REQUEST_SIZE ? count : MAX_REQUEST_SIZE; buf = calloc (limit, 1); @@ -532,9 +571,8 @@ plugin_zero (struct backend *b, struct connection *conn, } while (count) { - result = p->plugin.pwrite (connection_get_handle (conn, 0), -...