search for: threadlocal_key

Displaying 8 results from an estimated 8 matches for "threadlocal_key".

2017 Nov 17
1
Re: [nbdkit PATCH 2/4] threadlocal: Copy thread name
...off-by: Eric Blake <eblake@redhat.com> > --- > src/threadlocal.c | 17 +++++++++++++---- > 1 file changed, 13 insertions(+), 4 deletions(-) > > @@ -104,8 +105,16 @@ threadlocal_set_name (const char *name) > { > struct threadlocal *threadlocal = pthread_getspecific (threadlocal_key); > > - if (threadlocal) > - threadlocal->name = name; > + /* Copy name, as the original may be residing in a module, but we > + * want our thread name to persist even after unload. */ > + if (threadlocal) { > + free (threadlocal->name); > + threadlocal-...
2019 Apr 23
0
[PATCH nbdkit v2 2/2] server: Use a thread-local pread/pwrite buffer to avoid leaking heap data.
...it a/server/threadlocal.c b/server/threadlocal.c index e556dbc..49ae1ac 100644 --- a/server/threadlocal.c +++ b/server/threadlocal.c @@ -58,6 +58,8 @@ struct threadlocal { struct sockaddr *addr; socklen_t addrlen; int err; + void *buffer; + size_t buffer_size; }; static pthread_key_t threadlocal_key; @@ -69,6 +71,7 @@ free_threadlocal (void *threadlocalv) free (threadlocal->name); free (threadlocal->addr); + free (threadlocal->buffer); free (threadlocal); } @@ -189,3 +192,37 @@ threadlocal_get_error (void) errno = err; return threadlocal ? threadlocal->err : 0;...
2019 Apr 23
1
Re: [PATCH nbdkit v2 2/2] server: Use a thread-local pread/pwrite buffer to avoid leaking heap data.
...nbdkit_error() might be nicer than perror() anyways. I'll let you decide what, if any, error reporting needs to be done beyond merely sending ENOMEM to the client. > +extern void * > +threadlocal_buffer (size_t size) > +{ > + struct threadlocal *threadlocal = pthread_getspecific (threadlocal_key); > + > + if (!threadlocal) > + abort (); > + > + if (threadlocal->buffer_size < size) { > + void *ptr; > + > + ptr = realloc (threadlocal->buffer, size); > + if (ptr == NULL) { > + nbdkit_error ("threadlocal_buffer: realloc: %m");...
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
2017 Nov 17
7
[nbdkit PATCH 0/4] thread-safety issues prior to parallel handling
These patches should be ready to go in now; I will also post my work-in-progress for enabling full parallel handling that depends on these, but with that series, I was still getting crashes or hangs with test-socket-activation (I think I've nailed all the crashes I've seen, but the hang is rather insidious; see my other email
2017 Nov 17
0
[nbdkit PATCH 2/4] threadlocal: Copy thread name
...threadlocal (void *threadlocalv) { struct threadlocal *threadlocal = threadlocalv; + free (threadlocal->name); free (threadlocal->addr); free (threadlocal); } @@ -104,8 +105,16 @@ threadlocal_set_name (const char *name) { struct threadlocal *threadlocal = pthread_getspecific (threadlocal_key); - if (threadlocal) - threadlocal->name = name; + /* Copy name, as the original may be residing in a module, but we + * want our thread name to persist even after unload. */ + if (threadlocal) { + free (threadlocal->name); + threadlocal->name = strdup (name); + if (threa...
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
2019 Sep 18
1
[PATCH nbdkit] server: Remove useless thread local sockaddr.
...er); free (threadlocal); } @@ -133,22 +130,6 @@ threadlocal_set_instance_num (size_t instance_num) threadlocal->instance_num = instance_num; } -void -threadlocal_set_sockaddr (const struct sockaddr *addr, socklen_t addrlen) -{ - struct threadlocal *threadlocal = pthread_getspecific (threadlocal_key); - - if (threadlocal) { - free (threadlocal->addr); - threadlocal->addr = calloc (1, addrlen); - if (threadlocal->addr == NULL) { - perror ("calloc"); - exit (EXIT_FAILURE); - } - memcpy (threadlocal->addr, addr, addrlen); - } -} - const char * th...