Displaying 20 results from an estimated 154 matches for "pthread_mutex_unlock".
2019 Apr 24
7
[nbdkit PATCH 0/4] More mutex sanity checking
I do have a question about whether patch 2 is right, or whether I've
exposed a bigger problem in the truncate (and possibly other) filter,
but the rest seem fairly straightforward.
Eric Blake (4):
server: Check for pthread lock failures
truncate: Factor out reading real_size under mutex
plugins: Check for mutex failures
filters: Check for mutex failures
filters/cache/cache.c
2019 Apr 24
0
[nbdkit PATCH 4/4] filters: Check for mutex failures
...+ b/filters/cache/cache.c
@@ -209,9 +209,8 @@ cache_get_size (struct nbdkit_next_ops *next_ops, void *nxdata,
nbdkit_debug ("cache: underlying file size: %" PRIi64, size);
- pthread_mutex_lock (&lock);
+ ACQUIRE_LOCK_FOR_CURRENT_SCOPE (&lock);
r = blk_set_size (size);
- pthread_mutex_unlock (&lock);
if (r == -1)
return -1;
@@ -266,9 +265,10 @@ cache_pread (struct nbdkit_next_ops *next_ops, void *nxdata,
if (n > count)
n = count;
- pthread_mutex_lock (&lock);
- r = blk_read (next_ops, nxdata, blknum, block, err);
- pthread_mutex_unlock (&lo...
2017 Nov 17
0
[nbdkit PATCH 3/6] connections: Add read/write lock over client I/O
...recv_request_send_reply (struct connection *conn)
CLEANUP_FREE char *buf = NULL;
/* Read the request packet. */
+ pthread_mutex_lock (&conn->read_lock);
r = conn->recv (conn, &request, sizeof request);
if (r == -1) {
nbdkit_error ("read request: %m");
+ pthread_mutex_unlock (&conn->read_lock);
return -1;
}
if (r == 0) {
debug ("client closed input socket, closing connection");
+ pthread_mutex_unlock (&conn->read_lock);
return 0; /* disconnect */
}
magic = be32toh (request.magic);
if (magic !=...
2014 Mar 13
2
[PATCH] nouveau: safen up nouveau_device list usage against concurrent access
...ouveau_client **pclient)
clients = realloc(nvdev->client, sizeof(uint32_t) * (i + 1));
if (!clients)
- return ret;
+ goto unlock;
nvdev->client = clients;
nvdev->client[i] = 0;
nvdev->nr_client++;
@@ -214,6 +223,9 @@ out:
}
*pclient = &pcli->base;
+
+unlock:
+ pthread_mutex_unlock(&nvdev->lock);
return ret;
}
@@ -225,7 +237,9 @@ nouveau_client_del(struct nouveau_client **pclient)
if (pcli) {
int id = pcli->base.id;
nvdev = nouveau_device(pcli->base.device);
+ pthread_mutex_lock(&nvdev->lock);
nvdev->client[id / 32] &= ~(1 <<...
2017 Nov 17
8
[RFC nbdkit PATCH 0/6] Enable full parallel request handling
I want to make my nbd forwarding plugin fully parallel - but to do
that, I first need to make nbdkit itself fully parallel ;)
With this series, I was finally able to demonstrate out-of-order
responses when using qemu-io (which is great at sending back-to-back
requests prior to waiting for responses) coupled with the nbd file
plugin (which has a great feature of rdelay and wdelay, to make
it
2019 Apr 24
0
[nbdkit PATCH 1/4] server: Check for pthread lock failures
...nnection_get_status (struct connection *conn)
{
int r;
- if (conn->nworkers)
- pthread_mutex_lock (&conn->status_lock);
+ if (conn->nworkers &&
+ pthread_mutex_lock (&conn->status_lock))
+ abort ();
r = conn->status;
- if (conn->nworkers)
- pthread_mutex_unlock (&conn->status_lock);
+ if (conn->nworkers &&
+ pthread_mutex_unlock (&conn->status_lock))
+ abort ();
return r;
}
@@ -105,12 +107,14 @@ connection_get_status (struct connection *conn)
int
connection_set_status (struct connection *conn, int value)
{
- if (...
2017 Nov 17
2
Re: [nbdkit PATCH 3/6] connections: Add read/write lock over client I/O
...on *conn)
> CLEANUP_FREE char *buf = NULL;
>
> /* Read the request packet. */
> + pthread_mutex_lock (&conn->read_lock);
> r = conn->recv (conn, &request, sizeof request);
> if (r == -1) {
> nbdkit_error ("read request: %m");
> + pthread_mutex_unlock (&conn->read_lock);
> return -1;
> }
> if (r == 0) {
> debug ("client closed input socket, closing connection");
> + pthread_mutex_unlock (&conn->read_lock);
> return 0; /* disconnect */
> }
>
> magi...
2019 Apr 23
0
[nbdkit PATCH 4/4] plugins: Utilize ACQUIRE_LOCK_FOR_CURRENT_SCOPE
Now that cleanup.h is in common code, we can use it in our plugins
where it makes sense. Many uses of pthread_mutex_unlock() are not
function-wide, and over small enough snippets of code as to be easier
to read when left as-is; but when the scope is indeed function-wide or
across multiple exit paths, it is nicer to use the macro for automatic
unlock.
Signed-off-by: Eric Blake <eblake@redhat.com>
---
plugins/dat...
2014 Apr 08
0
[PATCH] libdrm/nouveau: safen up nouveau libdrm against concurrent access
...ient **pclient)
clients = realloc(nvdev->client, sizeof(uint32_t) * (i + 1));
if (!clients)
- return ret;
+ goto unlock;
nvdev->client = clients;
nvdev->client[i] = 0;
nvdev->nr_client++;
@@ -214,6 +223,9 @@ out:
}
*pclient = &pcli->base;
+
+unlock:
+ pthread_mutex_unlock(&nvdev->lock);
return ret;
}
@@ -225,7 +237,9 @@ nouveau_client_del(struct nouveau_client **pclient)
if (pcli) {
int id = pcli->base.id;
nvdev = nouveau_device(pcli->base.device);
+ pthread_mutex_lock(&nvdev->lock);
nvdev->client[id / 32] &= ~(1 &l...
2015 Feb 25
2
[PATCH 2/2] nouveau: Do not add most bo's to the global bo list.
...mutex_lock(&nvdev->lock);
> if (atomic_read(&nvbo->refcnt) == 0) {
> DRMLISTDEL(&nvbo->head);
> /*
> @@ -365,8 +365,6 @@ nouveau_bo_del(struct nouveau_bo *bo)
> }
> pthread_mutex_unlock(&nvdev->lock);
> } else {
> - DRMLISTDEL(&nvbo->head);
> - pthread_mutex_unlock(&nvdev->lock);
> drmIoctl(bo->device->fd, DRM_IOCTL_GEM_CLOSE, &req);
> }
> if (bo->map)
> @@ -3...
2019 Apr 24
0
[nbdkit PATCH 2/4] truncate: Factor out reading real_size under mutex
...*nxdata,
if (r == -1)
return -1;
- pthread_mutex_lock (&lock);
+ ACQUIRE_LOCK_FOR_CURRENT_SCOPE (&lock);
real_size = size = r;
@@ -163,8 +170,6 @@ truncate_get_size (struct nbdkit_next_ops *next_ops, void *nxdata,
size = ROUND_DOWN (size, round_down);
ret = size;
- pthread_mutex_unlock (&lock);
-
return ret;
}
@@ -176,11 +181,7 @@ truncate_pread (struct nbdkit_next_ops *next_ops, void *nxdata,
{
int r;
uint32_t n;
- uint64_t real_size_copy;
-
- pthread_mutex_lock (&lock);
- real_size_copy = real_size;
- pthread_mutex_unlock (&lock);
+ uint64_t real_si...
2015 Feb 25
2
[PATCH 2/2] nouveau: Do not add most bo's to the global bo list.
...if (atomic_read(&nvbo->refcnt) == 0) {
> >> DRMLISTDEL(&nvbo->head);
> >> /*
> >> @@ -365,8 +365,6 @@ nouveau_bo_del(struct nouveau_bo *bo)
> >> }
> >> pthread_mutex_unlock(&nvdev->lock);
> >> } else {
> >> - DRMLISTDEL(&nvbo->head);
> >> - pthread_mutex_unlock(&nvdev->lock);
> >> drmIoctl(bo->device->fd, DRM_IOCTL_GEM_CLOSE, &req);
> >>...
2015 Feb 24
0
[PATCH 2/2] nouveau: Do not add most bo's to the global bo list.
...;
- pthread_mutex_lock(&nvdev->lock);
- if (nvbo->name) {
+ if (nvbo->head.next) {
+ pthread_mutex_lock(&nvdev->lock);
if (atomic_read(&nvbo->refcnt) == 0) {
DRMLISTDEL(&nvbo->head);
/*
@@ -365,8 +365,6 @@ nouveau_bo_del(struct nouveau_bo *bo)
}
pthread_mutex_unlock(&nvdev->lock);
} else {
- DRMLISTDEL(&nvbo->head);
- pthread_mutex_unlock(&nvdev->lock);
drmIoctl(bo->device->fd, DRM_IOCTL_GEM_CLOSE, &req);
}
if (bo->map)
@@ -379,7 +377,6 @@ nouveau_bo_new(struct nouveau_device *dev, uint32_t flags, uint32_t align,...
2019 Apr 23
8
[nbdkit PATCH 0/4] Start using cleanup macros in filters/plugins
There's more that can be done (in particular, use of CLEANUP_FREE),
but this is enough to at least see if I'm on the right track.
I couldn't figure out an obvious difference between common/include and
common/utils, but it looks like the former is for things that are
inlineable via .h only, while the latter is when you need to link in
a convenience library, so this landed in the
2019 Apr 23
0
[nbdkit PATCH 3/4] filters: Utilize ACQUIRE_LOCK_FOR_CURRENT_SCOPE
Now that cleanup.h is in common code, we can use it in our filters
where it makes sense. Many uses of pthread_mutex_unlock() are not
function-wide, and over small enough snippets of code as to be easier
to read when left as-is; but when the scope is indeed function-wide or
across multiple exit paths, it is nicer to use the macro for automatic
unlock.
Signed-off-by: Eric Blake <eblake@redhat.com>
---
filters/log...
2015 Feb 24
4
[PATCH 1/2] nouveau: make nouveau importing global buffers completely thread-safe, with tests
...as to be closed with the lock held because
+ * gem handles are not refcounted. If a shared bo is
+ * closed and re-opened in another thread a race
+ * against DRM_IOCTL_GEM_OPEN or drmPrimeFDToHandle
+ * might cause the bo to be closed accidentally while
+ * re-importing.
*/
- pthread_mutex_unlock(&nvdev->lock);
- return;
+ drmIoctl(bo->device->fd, DRM_IOCTL_GEM_CLOSE, &req);
}
- DRMLISTDEL(&nvbo->head);
- /*
- * This bo has to be closed with the lock held because gem
- * handles are not refcounted. If a shared bo is closed and
- * re-opened in another...
2018 Dec 28
0
[PATCH nbdkit 5/9] cache: Allow this filter to serve requests in parallel.
...>get_size (nxdata);
if (size == -1)
@@ -139,7 +146,10 @@ cache_get_size (struct nbdkit_next_ops *next_ops, void *nxdata,
nbdkit_debug ("cache: underlying file size: %" PRIi64, size);
- if (blk_set_size (size))
+ pthread_mutex_lock (&lock);
+ r = blk_set_size (size);
+ pthread_mutex_unlock (&lock);
+ if (r == -1)
return -1;
return size;
@@ -179,6 +189,7 @@ cache_pread (struct nbdkit_next_ops *next_ops, void *nxdata,
while (count > 0) {
uint64_t blknum, blkoffs, n;
+ int r;
blknum = offset / BLKSIZE; /* block number */
blkoffs = offset % BLK...
2015 Feb 26
4
[PATCH v2 1/4] Add atomic_inc_return to atomics.
Signed-off-by: Maarten Lankhorst <maarten.lankhorst at ubuntu.com>
---
xf86atomic.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/xf86atomic.h b/xf86atomic.h
index 8c4b696..17fb088 100644
--- a/xf86atomic.h
+++ b/xf86atomic.h
@@ -49,6 +49,7 @@ typedef struct {
# define atomic_read(x) ((x)->atomic)
# define atomic_set(x, val) ((x)->atomic = (val))
# define atomic_inc(x)
2015 Feb 25
3
[PATCH 2/2] nouveau: Do not add most bo's to the global bo list.
...efcnt) == 0) {
> >>>> DRMLISTDEL(&nvbo->head);
> >>>> /*
> >>>> @@ -365,8 +365,6 @@ nouveau_bo_del(struct nouveau_bo *bo)
> >>>> }
> >>>> pthread_mutex_unlock(&nvdev->lock);
> >>>> } else {
> >>>> - DRMLISTDEL(&nvbo->head);
> >>>> - pthread_mutex_unlock(&nvdev->lock);
> >>>> drmIoctl(bo->device->fd, DRM_IOCTL_GEM_CLOS...
2004 Jul 30
1
Compiling * on OpenBSD 3.5
...editline/libedit.a db1-ast/libdb1.a stdtime/libtime.a -lncurses -lm -lssl
with lots of errors like:-
sched.o: In function `ast_sched_add':
/usr/src/asterisk/asterisk/sched.c:244: undefined reference to `pthread_mutex_lock'
/usr/src/asterisk/asterisk/sched.c:259: undefined reference to `pthread_mutex_unlock'
sched.o: In function `ast_sched_runq':
/usr/src/asterisk/asterisk/sched.c:351: undefined reference to `pthread_mutex_lock'
/usr/src/asterisk/asterisk/sched.c:378: undefined reference to `pthread_mutex_unlock'
/usr/src/asterisk/asterisk/sched.c:380: undefined reference to `pthread_m...