Displaying 20 results from an estimated 62 matches for "nbdkit_nanosleep".
2019 Aug 28
2
[PATCH nbdkit] freebsd: In nbdkit_nanosleep, fallback to calling nanosleep(2).
...---
server/public.c | 38 ++++++++++++++++++++++++--------------
1 file changed, 24 insertions(+), 14 deletions(-)
diff --git a/server/public.c b/server/public.c
index a992df1..630de9b 100644
--- a/server/public.c
+++ b/server/public.c
@@ -304,6 +304,16 @@ nbdkit_realpath (const char *path)
int
nbdkit_nanosleep (unsigned sec, unsigned nsec)
{
+ struct timespec ts;
+
+ if (sec >= INT_MAX - nsec / 1000000000) {
+ nbdkit_error ("sleep request is too long");
+ errno = EINVAL;
+ return -1;
+ }
+ ts.tv_sec = sec + nsec / 1000000000;
+ ts.tv_nsec = nsec % 1000000000;
+
#if defined HA...
2019 Aug 03
0
[nbdkit PATCH 3/3] server: Add and use nbdkit_nanosleep
...id processing our non-fatal
signal in the same thread as any filter/plugin processing, or by
paying attention to EINTR results and restarting a sleep. And rather
than making each sleeping client reimplement that logic, we might as
well stick it in on our common helper.
Thus, this patch introduces nbdkit_nanosleep, and implements it under
the hood as a ppoll that redirects signals but wakes up as needed.
Including <time.h> for struct timespec in nbdkit-common.h is difficult
(C++ is not required to provide it), so we just take the two arguments
in pieces; we can rely on int being 32-bits, so don't n...
2019 Aug 05
1
Re: [nbdkit PATCH 3/3] server: Add and use nbdkit_nanosleep
On 8/3/19 11:01 AM, Eric Blake wrote:
> There are a couple of problems with filters trying to sleep. First,
> when it is time to shut down nbdkit, we wait until all pending
> transactions have had a chance to wind down. But consider what
> happens if one or more of those pending transactions are blocked in a
> sleep. POSIX says nanosleep is interrupted with EINTR if that thread
2019 Aug 28
0
Re: [PATCH nbdkit] freebsd: In nbdkit_nanosleep, fallback to calling nanosleep(2).
On 8/28/19 11:14 AM, Richard W.M. Jones wrote:
> Rather than failing to compile on platforms which lack POLLRDHUP such
> as FreeBSD, simply fallback to the old method of sleeping.
>
> This leaves the porting suggestions as a comment in case someone wants
> to implement a better solution for particular platforms.
> ---
> server/public.c | 38
2019 Aug 03
5
[nbdkit PATCH 0/3] More responsive shutdown
...oint where the main thread
has tried to unload the plugin, which is never a nice thing. We may
still have more work ahead of us to ensure that we don't unload an
in-use plugin.
Eric Blake (3):
server: Add threadlocal_get_conn
server: Add pipe for tracking disconnects
server: Add and use nbdkit_nanosleep
docs/nbdkit-plugin.pod | 28 +++++++++++++++++
configure.ac | 1 +
include/nbdkit-common.h | 1 +
server/internal.h | 3 ++
filters/delay/delay.c | 14 ++-------
filters/rate/rate.c | 10 +++----
server/connections.c | 66 ++++++++++++++++++++++++++++++++++++++++-
se...
2020 Mar 26
0
[PATCH nbdkit 5/9 patch split 5/5] server: Indirect slow path, non-self-contained functions through the server.
...c */
extern struct backend *filter_register (struct backend *next, size_t index,
@@ -515,6 +517,11 @@ extern void *threadlocal_buffer (size_t size);
extern void threadlocal_set_conn (struct connection *conn);
extern struct connection *threadlocal_get_conn (void);
+/* public.c */
+extern int do_nbdkit_nanosleep (unsigned sec, unsigned nsec);
+extern const char *do_nbdkit_export_name (void);
+extern int do_nbdkit_peer_name (struct sockaddr *addr, socklen_t *addrlen);
+
/* Macro which sets local variable struct connection *conn from
* thread-local storage, asserting that it is non-NULL. If you want
*...
2019 Aug 06
1
[nbdkit PATCH] tests: Test for faster shutdown
The test relies on the timeout program. Also, since the
nbdkit_nanosleep code relies on the Linux extension POLLRDHUP to
detect early client closure, we may have to relax that part of the
test when porting to platforms that lack ppoll/POLLRDHUP. (That is,
while we should still be able to let a signal to the server shut down
nbdkit quickly, it's harder to let a clie...
2020 Feb 11
0
[PATCH nbdkit 1/3] server: Add GET_CONN macro, alias for threadlocal_get_conn ().
...n *threadlocal_get_conn (void);
+#define GET_CONN (threadlocal_get_conn ())
/* Declare program_name. */
#if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME == 1
diff --git a/server/public.c b/server/public.c
index 418945fe..8fa7e21b 100644
--- a/server/public.c
+++ b/server/public.c
@@ -533,7 +533,7 @@ nbdkit_nanosleep (unsigned sec, unsigned nsec)
* NBD_CMD_DISC or a problem with the connection
* - the input socket detects POLLRDHUP/POLLHUP/POLLERR
*/
- struct connection *conn = threadlocal_get_conn ();
+ struct connection *conn = GET_CONN;
struct pollfd fds[] = {
[0].fd = quit_fd,
[...
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
2
Re: nbdkit / mingw support
...I had a look into how we might implement libnbdkit.so. Some functions
> are 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)
Yeah, there's some awkward dependencies to figure out. It's obvious the
library has...
2020 Mar 25
0
Re: nbdkit / mingw support
...ouldn't be
a source API break.
I had a look into how we might implement libnbdkit.so. Some functions
are 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...
2019 Sep 15
0
[PATCH nbdkit 3/4] server: Add nbdkit_peer_name() to return the client address.
...#include <stdarg.h>
#include <stdint.h>
#include <errno.h>
+#include <sys/socket.h>
#include <nbdkit-version.h>
@@ -87,6 +88,7 @@ extern int nbdkit_read_password (const char *value, char **password);
extern char *nbdkit_realpath (const char *path);
extern int nbdkit_nanosleep (unsigned sec, unsigned nsec);
extern const char *nbdkit_export_name (void);
+extern int nbdkit_peer_name (struct sockaddr *addr, socklen_t *addrlen);
struct nbdkit_extents;
extern int nbdkit_add_extent (struct nbdkit_extents *,
diff --git a/server/nbdkit.syms b/server/nbdkit.syms
index 1fb131...
2020 Aug 02
2
[nbdkit] Failure in test-retry-size.sh
This happened on s390 in Koji, once. The key lines from the
log are:
+ start_t=0
nbdkit: sh[1]: debug: retry 1: waiting 1 seconds before retrying
nbdkit: sh[1]: debug: retry 1: waiting 1 seconds before retrying
+ end_t=1
Somehow nbdkit did wait 2 seconds (or at least, nbdkit_nanosleep (1, 0)
was called twice by the retry filter). But in the bash script, time
(as measured by $SECONDS) advanced from 0 to 1.
I'm not sure I can explain that ...
It should be possible to make the test more robust by increasing the
retry time and subtracting a bit of slop in the test of end_t -...
2020 Aug 18
0
[PATCH nbdkit 8/9] include: Prefix all exports with NBDKIT_DLLEXPORT.
...64_t *r);
-extern int nbdkit_parse_uint64_t (const char *what, const char *str,
- uint64_t *r);
-extern int nbdkit_stdio_safe (void);
-extern int nbdkit_read_password (const char *value, char **password);
-extern char *nbdkit_realpath (const char *path);
-extern int nbdkit_nanosleep (unsigned sec, unsigned nsec);
-extern int nbdkit_peer_name (struct sockaddr *addr, socklen_t *addrlen);
-extern void nbdkit_shutdown (void);
+extern NBDKIT_DLLEXPORT char *nbdkit_absolute_path (const char *path);
+extern NBDKIT_DLLEXPORT int64_t nbdkit_parse_size (const char *str);
+extern NBDKIT_...
2020 Mar 04
0
[PATCH nbdkit 1/4] tests: Rename test-shutdown.sh to test-delay-shutdown.sh.
...lay-shutdown.sh
@@ -37,7 +37,7 @@ requires qemu-io --version
requires timeout --version
sock=`mktemp -u`
-files="shutdown.pid $sock"
+files="delay-shutdown.pid $sock"
cleanup_fn rm -f $files
fail=0
@@ -45,7 +45,7 @@ fail=0
# This tests that the delay filter's use of nbdkit_nanosleep is able to
# react to both connection death and server shutdown without finishing
# the entire delay duration.
-start_nbdkit -P shutdown.pid -U $sock --filter=noparallel --filter=delay \
+start_nbdkit -P delay-shutdown.pid -U $sock --filter=noparallel --filter=delay \
null 1M serialize=conne...
2020 Mar 26
9
[PATCH nbdkit 5/9 patch split 1/5] Create libnbdkit.so.
This is the previous 5/9 patch posted earlier today, split into
reviewable chunks. This passes bisection with -x 'make && make
check', but I didn't work very hard on the commit messages, so I refer
you back to the original patch to explain how it works:
https://www.redhat.com/archives/libguestfs/2020-March/msg00248.html
Rich.
2020 Mar 25
0
Re: nbdkit / mingw support
...ht implement libnbdkit.so. Some functions
> >are 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)
>
> Yeah, there's some awkward dependencies to figure out. It's obv...
2020 Mar 23
0
[PATCH nbdkit 2/3] server: Inject API functions for Windows
...;
+ functions->parse_uint32_t = nbdkit_parse_uint32_t;
+ functions->parse_int64_t = nbdkit_parse_int64_t;
+ functions->parse_uint64_t = nbdkit_parse_uint64_t;
+ functions->read_password = nbdkit_read_password;
+ functions->realpath = nbdkit_realpath;
+ functions->nanosleep = nbdkit_nanosleep;
+ functions->export_name = nbdkit_export_name;
+ functions->peer_name = dummy_peer_name;
+ functions->shutdown = nbdkit_shutdown;
+ functions->add_extent = nbdkit_add_extent;
+ functions->extents_new = nbdkit_extents_new;
+ functions->extents_free = nbdkit_extents_free;
+...
2020 Aug 03
0
Re: [nbdkit] Failure in test-retry-size.sh
...d on s390 in Koji, once. The key lines from the
> log are:
>
> + start_t=0
> nbdkit: sh[1]: debug: retry 1: waiting 1 seconds before retrying
> nbdkit: sh[1]: debug: retry 1: waiting 1 seconds before retrying
> + end_t=1
>
> Somehow nbdkit did wait 2 seconds (or at least, nbdkit_nanosleep (1, 0)
> was called twice by the retry filter). But in the bash script, time
> (as measured by $SECONDS) advanced from 0 to 1.
FWIW $SECONDS is calculated by bash in the obvious way. It saves
time(2) when the shell starts, and then when you ask for $SECONDS it
returns the current time(2) -...
2019 Sep 12
4
[PATCH nbdkit v2 0/3] Access export name from plugins.
The previous incomplete patch was here:
https://www.redhat.com/archives/libguestfs/2019-September/msg00049.html
based on earlier discussion here:
https://www.redhat.com/archives/libguestfs/2019-September/msg00047.html
In v2:
- The previous patch was incomplete. This version completes it by
adding tests and extending nbdkit-sh-plugin.
- nbdkit_export_name now returns NULL for error,