search for: pthread_mutex_initializer

Displaying 20 results from an estimated 132 matches for "pthread_mutex_initializer".

2018 Jan 17
0
[PATCH 1/9] plugins: Move locking to a new file.
...IGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <config.h> + +#include <stdio.h> +#include <stdlib.h> + +#include "internal.h" + +static pthread_mutex_t connection_lock = PTHREAD_MUTEX_INITIALIZER; +static pthread_mutex_t all_requests_lock = PTHREAD_MUTEX_INITIALIZER; +static pthread_rwlock_t unload_prevention_lock = PTHREAD_RWLOCK_INITIALIZER; + +void +lock_connection (void) +{ + int thread_model = plugin_thread_model (); + + if (thread_model <= NBDKIT_THREAD_MODEL_SERIALIZE_CONNECTION...
2018 Jan 16
0
[PATCH nbdkit 1/3] plugins: Move locking to a new file.
...IGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <config.h> + +#include <stdio.h> +#include <stdlib.h> + +#include "internal.h" + +static pthread_mutex_t connection_lock = PTHREAD_MUTEX_INITIALIZER; +static pthread_mutex_t all_requests_lock = PTHREAD_MUTEX_INITIALIZER; +static pthread_rwlock_t unload_prevention_lock = PTHREAD_RWLOCK_INITIALIZER; + +void +lock_connection (void) +{ + int thread_model = plugin_thread_model (); + + if (thread_model <= NBDKIT_THREAD_MODEL_SERIALIZE_CONNECTION...
2017 Nov 14
0
[PATCH 2/3] Avoid race conditions when nbdkit exits.
...uld always be called. + */ + if (!quit) { + if (conn->handle) + plugin_close (conn); + } free (conn); } diff --git a/src/plugins.c b/src/plugins.c index d2d0b39..f5056d9 100644 --- a/src/plugins.c +++ b/src/plugins.c @@ -48,6 +48,7 @@ static pthread_mutex_t connection_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t all_requests_lock = PTHREAD_MUTEX_INITIALIZER; +static pthread_rwlock_t unload_prevention_lock = PTHREAD_RWLOCK_INITIALIZER; /* Maximum read or write request that we will handle. */ #define MAX_REQUEST_SIZE (64 * 1024 * 1024) @@ -155,6 +156,11 @@ void plugin_cleanup (v...
2018 Jan 25
1
[nbdkit PATCH] errors: Use lighter-weight locking
...* All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -44,21 +44,16 @@ #include "nbdkit-plugin.h" #include "internal.h" -/* Used to group piecemeal message construction into atomic output. */ -static pthread_mutex_t errors_lock = PTHREAD_MUTEX_INITIALIZER; - static void lock (void) { - int r = pthread_mutex_lock (&errors_lock); - assert (!r); + flockfile (stderr); } static void unlock (void) { - int r = pthread_mutex_unlock (&errors_lock); - assert (!r); + funlockfile (stderr); } /* Called with lock taken. */ -- 2.14.3
2018 Jan 19
1
[PATCH nbdkit] locks: Cache the plugin thread model.
...b2dd0..bd8fd99 100644 --- a/src/locks.c +++ b/src/locks.c @@ -38,15 +38,24 @@ #include "internal.h" +/* Note that the plugin's thread model cannot change after being + * loaded, so caching it here is safe. + */ +static int thread_model; + static pthread_mutex_t connection_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t all_requests_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_rwlock_t unload_prevention_lock = PTHREAD_RWLOCK_INITIALIZER; void -lock_connection (void) +lock_init_thread_model (void) { - int thread_model = backend->thread_model (backend); + thread_model = backend...
2020 Aug 06
1
Re: [PATCH nbdkit 1/2] vddk: Relax threading model: SERIALIZE_ALL_REQUESTS -> SERIALIZE_REQUESTS.
...same. I think Eric already wrote about this. */ > -#define THREAD_MODEL NBDKIT_THREAD_MODEL_SERIALIZE_ALL_REQUESTS > +#define THREAD_MODEL NBDKIT_THREAD_MODEL_SERIALIZE_REQUESTS > + > +/* Lock protecting open/close calls - see above. */ > +static pthread_mutex_t open_close_lock = PTHREAD_MUTEX_INITIALIZER; > > /* The per-connection handle. */ > struct vddk_handle { > @@ -524,6 +531,7 @@ free_connect_params (VixDiskLibConnectParams *params) > static void * > vddk_open (int readonly) > { > + ACQUIRE_LOCK_FOR_CURRENT_SCOPE (&open_close_lock); > struct vddk_handle...
2018 Aug 01
1
Re: [PATCH v2 nbdkit 5/6] Add truncate filter for truncating or extending the size of plugins.
...= 0; > + > +/* The real size of the underlying plugin. */ > +static uint64_t real_size; > + > +/* The calculated size after applying the parameters. */ > +static uint64_t size; > + > +/* This lock protects the real_size and size fields. */ > +static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; Do we need the lock, or can we rely on the fact that .prepare will get called before anything else, and treat these as always initialized after that point? > + /* The truncate, round-up and round-down parameters are treated as > + * separate operations. It's possible to specify...
2020 Aug 15
2
Re: [PATCH nbdkit] New ondemand plugin.
...re extra fields we could be providing to journald. > >+++ b/plugins/ondemand/ondemand.c > > >+/* Because we rewind the exportsdir handle, we need a lock to protect > >+ * list_exports from being called in parallel. > >+ */ > >+static pthread_mutex_t exports_lock = PTHREAD_MUTEX_INITIALIZER; > > An alternative is to diropen() each time .list_exports gets called. > Either way should work, though. diropen == opendir? > I still have some pending patches to improve .list_exports (split > out a .default_export function, add an is_tls parameter), so there > may be some...
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 Mar 23
1
Re: [PATCH nbdkit 8/8] file: Implement extents.
....c | 139 ++++++++++++++++++++++++++++++++++++++++---- > 1 file changed, 129 insertions(+), 10 deletions(-) > > -int file_debug_zero; /* to enable: -D file.zero=1 */ > +/* Any callbacks using lseek must be protected by this lock. */ > +static pthread_mutex_t lseek_lock = PTHREAD_MUTEX_INITIALIZER; > + > +/* to enable: -D file.zero=1 */ > +int file_debug_zero; > > static void > file_unload (void) > @@ -220,6 +227,21 @@ file_close (void *handle) > > #define THREAD_MODEL NBDKIT_THREAD_MODEL_PARALLEL > > +/* For block devices, stat->st_size is not th...
2019 May 15
6
[nbdkit PATCH v2] Introduce cacheextents filter
...t;string.h> +#include <errno.h> +#include <inttypes.h> + +#include <pthread.h> + +#include <nbdkit-filter.h> + +#include "cleanup.h" + +#define THREAD_MODEL NBDKIT_THREAD_MODEL_PARALLEL + +/* This lock protects the global state. */ +static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; + +/* The real size of the underlying plugin. */ +static uint64_t size; + +/* Cached extents from the last extents () call and its start and end for the + sake of simplicity. */ +struct nbdkit_extents *cache_extents; +static uint64_t cache_start; +static uint64_t cache_end; + +static void +cache...
2018 Nov 08
1
[nbdkit PATCH] log: Allow user option of appending to log
...@ #include <pthread.h> #include <sys/time.h> #include <assert.h> +#include <stdbool.h> #include <nbdkit-filter.h> @@ -51,6 +52,7 @@ static uint64_t connections; static char *logfilename; static FILE *logfile; +static bool append; static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; static void @@ -75,6 +77,10 @@ log_config (nbdkit_next_config *next, void *nxdata, } return 0; } + if (strcmp (key, "logappend") == 0) { + append = value[0] && (value[0] != '0' || value[1]); + return 0; + } return next (nxdata, key, value); } @...
2023 Feb 22
1
[PATCH nbdkit] curl: Try to share as much as possible between handles in the pool
...rl share data. See: + * https://gist.github.com/bagder/7eccf74f8b6d70b5abefeb7f288dba9b + */ +static pthread_rwlock_t lockarray[CURL_LOCK_DATA_LAST]; + +/* Curl share data. */ +static CURLSH *share; /* This lock protects access to the curl_handles vector below. */ static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; @@ -90,18 +103,46 @@ static curl_handle_list curl_handles = empty_vector; static pthread_cond_t cond = PTHREAD_COND_INITIALIZER; static size_t in_use = 0, waiting = 0; -/* Close and free all handles in the pool. */ +/* Initialize pool structures. */ void -free_all_handles (void) +load_pool (v...
2020 Aug 06
5
[PATCH nbdkit NOT WORKING 0/2] vddk: Relax threading model.
I believe this roughly implements Nir's proposal here: https://www.redhat.com/archives/libguestfs/2020-August/msg00028.html Unfortunately it doesn't work for me. It actually slows things down quite a lot, for reasons I don't understand. Note the adjustment of the pool-max parameter and how it affects the total time. The results are quite reproducible. $ ./nbdkit -r -U - vddk
2019 May 19
4
most robust way to call R API functions from a secondary thread
...ntptr_t R_CStackLimit; extern int R_PPStackTop; extern int R_PPStackSize; #include <R_ext/libextern.h> LibExtern Rboolean R_interrupts_suspended; LibExtern int R_interrupts_pending; extern void Rf_onintr(void); // mutex for exclusive access to the R API: static pthread_mutex_t r_api_mutex = PTHREAD_MUTEX_INITIALIZER; // a wrapper arround R_CheckUserInterrupt() which can be passed to R_UnwindProtect(): SEXP check_interrupt(void *data) { R_CheckUserInterrupt(); return R_NilValue; } // a wrapper arround Rf_onintr() which can be passed to R_UnwindProtect(): SEXP my_onintr(void *data) { Rf_onintr(); retur...
2020 Aug 07
2
[PATCH nbdkit] plugins: file: More standard cache mode names
...t fadvise_mode = ; /* cache mode */ -static enum { cache_default, cache_none } cache_mode = cache_default; +static enum { cache_writeback, cache_writethrough } cache_mode = cache_writeback; /* Any callbacks using lseek must be protected by this lock. */ static pthread_mutex_t lseek_lock = PTHREAD_MUTEX_INITIALIZER; @@ -140,10 +140,10 @@ file_config (const char *key, const char *value) } } else if (strcmp (key, "cache") == 0) { - if (strcmp (value, "default") == 0) - cache_mode = cache_default; - else if (strcmp (value, "none") == 0) - cache_mode = cach...
2019 Aug 13
3
[nbdkit PATCH 0/2] errno cleanup patches
I ran into these while trying to prepare patches to add NBD_CMD_FLAG_FAST_ZERO, which will expose a new NBD_ENOTSUP wire value. Eric Blake (2): plugins: Don't lose original error when emulating FUA plugins: Permit ENOTSUP as synonym for EOPNOTSUPP docs/nbdkit-filter.pod | 11 ++++++----- docs/nbdkit-plugin.pod | 12 +++++++----- plugins/file/file.c | 16 +++++++++++-----
2019 Oct 10
1
[PATCH NOT WORKING nbdkit] vddk: Restructure plugin to allow greater parallelism.
We had a query yesterday about the VDDK plugin and making it actually obey the weird "Multithreading Considerations" rules in the VDDK documentation (https://vdc-download.vmware.com/vmwb-repository/dcr-public/8f96698a-0e7b-4d67-bb6c-d18a1d101540/ef536a47-27cd-481a-90ef-76b38e75353c/vsphere-vddk-671-programming-guide.pdf) This patch is my attempt to implement this. The idea is that the
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 1/4] errors: Avoid interleaved errors from parallel threads
...rg.h> #include <string.h> #include <errno.h> +#include <assert.h> +#include <pthread.h> #include "nbdkit-plugin.h" #include "internal.h" +/* Used to group piecemeal message construction into atomic output. */ +static pthread_mutex_t errors_lock = PTHREAD_MUTEX_INITIALIZER; + +static void +lock (void) +{ + int r = pthread_mutex_lock(&errors_lock); + assert(!r); +} + +static void +unlock (void) +{ + int r = pthread_mutex_unlock(&errors_lock); + assert(!r); +} + +/* Called with lock taken. */ static void prologue (const char *type) { @@ -69,11 +89,13 @@...