Displaying 20 results from an estimated 38 matches for "threadlocal_get_conn".
2020 Feb 11
1
Re: [PATCH nbdkit 1/3] server: Add GET_CONN macro, alias for threadlocal_get_conn ().
...7309..1e7b4cf0 100644
> --- a/server/internal.h
> +++ b/server/internal.h
> @@ -493,6 +493,7 @@ extern int threadlocal_get_error (void);
> extern void *threadlocal_buffer (size_t size);
> extern void threadlocal_set_conn (struct connection *conn);
> extern struct connection *threadlocal_get_conn (void);
> +#define GET_CONN (threadlocal_get_conn ())
Do we want any checking, such as whether this is non-NULL?
For example, patch 3 has:
-typedef void (*connection_close_function) (struct connection *)
__attribute__((__nonnull__ (1)));
+typedef void (*connection_close_function) (void);...
2020 Feb 11
0
[PATCH nbdkit 1/3] server: Add GET_CONN macro, alias for threadlocal_get_conn ().
....h b/server/internal.h
index a1fa7309..1e7b4cf0 100644
--- a/server/internal.h
+++ b/server/internal.h
@@ -493,6 +493,7 @@ extern int threadlocal_get_error (void);
extern void *threadlocal_buffer (size_t size);
extern void threadlocal_set_conn (struct connection *conn);
extern struct connection *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 (unsig...
2020 Mar 25
2
Re: nbdkit / mingw support
...s
> 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 to export public nbdkit_* interfaces for the sake of
plugins, but can it...
2020 Mar 26
0
[PATCH nbdkit 5/9 patch split 3/5] server: Move some definitions in server/internal.h to the top of the file.
...se \
- nbdkit_debug ((fs), ##__VA_ARGS__); \
- } while (0)
-
/* debug-flags.c */
extern void add_debug_flag (const char *arg);
extern void apply_debug_flags (void *dl, const char *name);
@@ -517,12 +524,4 @@ extern struct connection *threadlocal_get_conn (void);
struct connection *conn = threadlocal_get_conn (); \
assert (conn != NULL)
-/* Declare program_name. */
-#if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME == 1
-#include <errno.h>
-#define program_name program_invocation_short_name
-#else
-#define program_name "nbdkit"...
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 Apr 28
2
[PATCH nbdkit] server/locks: Allow lock_request to be called when there is no current conn.
...ocks.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/server/locks.c b/server/locks.c
index 5d54d311..9269c75e 100644
--- a/server/locks.c
+++ b/server/locks.c
@@ -93,7 +93,7 @@ unlock_connection (void)
void
lock_request (void)
{
- GET_CONN;
+ struct connection *conn = threadlocal_get_conn ();
if (thread_model <= NBDKIT_THREAD_MODEL_SERIALIZE_ALL_REQUESTS &&
pthread_mutex_lock (&all_requests_lock))
@@ -110,7 +110,7 @@ lock_request (void)
void
unlock_request ()
{
- GET_CONN;
+ struct connection *conn = threadlocal_get_conn ();
if (pthread_rwlock_un...
2020 Mar 25
0
Re: nbdkit / mingw support
...ntained (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 to export public nbdkit_* interfaces for the sake o...
2020 Aug 27
0
[nbdkit PATCH v2 2/8] api: Add nbdkit_add_default_export
...nbdkit_exports *));
/* A static non-NULL pointer which can be used when you don't need a
* per-connection handle.
diff --git a/server/internal.h b/server/internal.h
index 8c8448e6..e2a68513 100644
--- a/server/internal.h
+++ b/server/internal.h
@@ -543,4 +543,8 @@ extern struct connection *threadlocal_get_conn (void);
struct connection *conn = threadlocal_get_conn (); \
assert (conn != NULL)
+/* exports.c */
+extern int exports_resolve_default (struct nbdkit_exports *exports,
+ struct backend *b, int readonly);
+
#endif /* NBDKIT_INTERNAL_H */
diff --git a/se...
2020 Mar 26
0
[PATCH nbdkit 5/9 patch split 5/5] server: Indirect slow path, non-self-contained functions through the server.
...));
+extern void do_nbdkit_set_error (int err);
/* filters.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...
2019 Aug 03
5
[nbdkit PATCH 0/3] More responsive shutdown
...t returns means we still have cases where our
detached threads are executing past the point 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...
2020 Feb 11
1
Re: [PATCH nbdkit 3/3] server: Remove explicit connection parameter, use TLS instead.
On 2/11/20 11:15 AM, Richard W.M. Jones wrote:
> Since commit 86fdb48c6a5362d66865493d9d2172166f99722e we have stored
> the connection object in thread-local storage.
>
> In this very large, but mostly mechanical change we stop passing the
> connection pointer around everywhere, and instead use the value stored
> in thread-local storage.
>
> This assumes a 1-1 mapping
2020 Aug 27
2
Re: [nbdkit PATCH v2 2/8] api: Add nbdkit_add_default_export
...atic non-NULL pointer which can be used when you don't need a
> * per-connection handle.
> diff --git a/server/internal.h b/server/internal.h
> index 8c8448e6..e2a68513 100644
> --- a/server/internal.h
> +++ b/server/internal.h
> @@ -543,4 +543,8 @@ extern struct connection *threadlocal_get_conn (void);
> struct connection *conn = threadlocal_get_conn (); \
> assert (conn != NULL)
>
> +/* exports.c */
> +extern int exports_resolve_default (struct nbdkit_exports *exports,
> + struct backend *b, int readonly);
> +
> #endif...
2020 Aug 25
0
[nbdkit PATCH 3/5] api: Add nbdkit_string_intern helper
...- a/server/public.c
+++ b/server/public.c
@@ -726,3 +726,45 @@ nbdkit_peer_name (struct sockaddr *addr, socklen_t *addrlen)
return 0;
}
+
+/* Functions for manipulating intern'd strings. */
+
+static string_vector global_interns;
+
+void
+free_interns (void)
+{
+ struct connection *conn = threadlocal_get_conn ();
+ string_vector *list = conn ? &conn->interns : &global_interns;
+
+ string_vector_iter (list, (void *) free);
+ string_vector_reset (list);
+}
+
+const char *
+nbdkit_string_intern (const char *str)
+{
+ struct connection *conn = threadlocal_get_conn ();
+ string_vector *list =...
2019 Aug 05
1
Re: [nbdkit PATCH 3/3] server: Add and use nbdkit_nanosleep
...for
> activities on those pipes in parallel with a timeout through pselect
> or ppoll to break our wait as soon as we know there is no reason to
> continue on with the transaction.
>
> +++ b/server/public.c
> +#else
> + struct timespec ts;
> + struct connection *conn = threadlocal_get_conn ();
> + struct pollfd fds[2] = {
> + [0].fd = quit_fd,
> + [0].events = POLLIN,
> + [1].fd = conn ? conn->status_pipe[0] : -1,
> + [1].events = POLLIN,
In testing this, the code is responsive to a multi-threaded connection
detecting client death on any other thread,...
2020 Aug 27
0
[nbdkit PATCH v2 4/8] api: Add nbdkit_str[n]dup_intern helper
...- a/server/public.c
+++ b/server/public.c
@@ -726,3 +726,51 @@ nbdkit_peer_name (struct sockaddr *addr, socklen_t *addrlen)
return 0;
}
+
+/* Functions for manipulating intern'd strings. */
+
+static string_vector global_interns;
+
+void
+free_interns (void)
+{
+ struct connection *conn = threadlocal_get_conn ();
+ string_vector *list = conn ? &conn->interns : &global_interns;
+
+ string_vector_iter (list, (void *) free);
+ string_vector_reset (list);
+}
+
+const char *
+nbdkit_strndup_intern (const char *str, size_t n)
+{
+ struct connection *conn = threadlocal_get_conn ();
+ string_vec...
2020 Mar 25
0
Re: nbdkit / mingw support
...ght 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 awkward. The quit flag is still
more awkward because you have to m...
2019 Sep 15
0
[PATCH nbdkit 3/4] server: Add nbdkit_peer_name() to return the client address.
...ll.h>
#include <signal.h>
+#include <sys/socket.h>
#include "get-current-dir-name.h"
@@ -392,3 +393,23 @@ nbdkit_export_name (void)
return conn->exportname;
}
+
+int
+nbdkit_peer_name (struct sockaddr *addr, socklen_t *addrlen)
+{
+ struct connection *conn = threadlocal_get_conn ();
+ int s;
+
+ if (!conn) {
+ nbdkit_error ("no connection in this thread");
+ return -1;
+ }
+
+ s = conn->sockin;
+ if (s == -1) {
+ nbdkit_error ("socket not open");
+ return -1;
+ }
+
+ return getpeername (s, addr, addrlen);
+}
--
2.23.0
2019 Aug 28
2
[PATCH nbdkit] freebsd: In nbdkit_nanosleep, fallback to calling nanosleep(2).
...* - nbdkit has received a signal to shut down the server
@@ -311,7 +321,6 @@ nbdkit_nanosleep (unsigned sec, unsigned nsec)
* NBD_CMD_DISC or a problem with the connection
* - the input socket detects POLLRDHUP/POLLHUP/POLLERR
*/
- struct timespec ts;
struct connection *conn = threadlocal_get_conn ();
struct pollfd fds[] = {
[0].fd = quit_fd,
@@ -323,14 +332,6 @@ nbdkit_nanosleep (unsigned sec, unsigned nsec)
};
sigset_t all;
- if (sec >= INT_MAX - nsec / 1000000000) {
- nbdkit_error ("sleep request is too long");
- errno = EINVAL;
- return -1;
- }
-...
2020 Feb 11
5
[PATCH nbdkit 0/3] server: Remove explicit connection parameter.
The third patch is a large but mechanical change which gets rid of
passing around struct connection * entirely within the server,
preferring instead to reference the connection through thread-local
storage.
I hope this is a gateway to simplifying other parts of the code.
Rich.
2019 Sep 10
0
[PATCH nbdkit] server: Add nbdkit_export_name() to allow export name to be read.
...request it!
diff --git a/server/public.c b/server/public.c
index 630de9b..eb7f996 100644
--- a/server/public.c
+++ b/server/public.c
@@ -379,3 +379,13 @@ nbdkit_nanosleep (unsigned sec, unsigned nsec)
return 0;
#endif
}
+
+const char *
+nbdkit_export_name (void)
+{
+ struct connection *conn = threadlocal_get_conn ();
+
+ if (!conn)
+ return NULL;
+ return conn->exportname;
+}
--
2.23.0