Richard W.M. Jones
2020-Apr-28 16:45 UTC
[Libguestfs] [PATCH nbdkit] server/locks: Allow lock_request to be called when there is no current conn.
On Haiku tests/test-socket-activation failed with: nbdkit: locks.c:96:lock_request: conn != NULL called from server/sockets.c: accept_connection in the fallback path which does: lock_request (); thread_data->sock = set_cloexec (accept (listen_sock, NULL, NULL)); unlock_request () Because there is no current connection in this thread this code fails. However it should be possible to call lock_request without a connection, provided that thread_model <= NBDKIT_THREAD_MODEL_SERIALIZE_REQUESTS (which it is when the fallback path is engaged on Haiku). There was a regression caused when I modified to code to use an implicit TLS connection. Fixes commit 91023f269d4cea56f573a1aa0d880b12052f6e1e. --- server/locks.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_unlock (&unload_prevention_lock)) abort (); -- 2.25.0
Eric Blake
2020-Apr-28 17:29 UTC
Re: [Libguestfs] [PATCH nbdkit] server/locks: Allow lock_request to be called when there is no current conn.
On 4/28/20 11:45 AM, Richard W.M. Jones wrote:> On Haiku tests/test-socket-activation failed with: > > nbdkit: locks.c:96:lock_request: conn != NULL > > called from server/sockets.c: accept_connection > in the fallback path which does: > lock_request (); > thread_data->sock = set_cloexec (accept (listen_sock, NULL, NULL)); > unlock_request () > > Because there is no current connection in this thread this code fails. > > However it should be possible to call lock_request without a > connection, provided that > thread_model <= NBDKIT_THREAD_MODEL_SERIALIZE_REQUESTS (which it is > when the fallback path is engaged on Haiku). There was a regression > caused when I modified to code to use an implicit TLS connection. > > Fixes commit 91023f269d4cea56f573a1aa0d880b12052f6e1e. > --- > server/locks.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-)ACK -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Richard W.M. Jones
2020-Apr-28 17:48 UTC
Re: [Libguestfs] [PATCH nbdkit] server/locks: Allow lock_request to be called when there is no current conn.
On Tue, Apr 28, 2020 at 12:29:47PM -0500, Eric Blake wrote:> On 4/28/20 11:45 AM, Richard W.M. Jones wrote: > >On Haiku tests/test-socket-activation failed with: > > > >nbdkit: locks.c:96:lock_request: conn != NULL > > > >called from server/sockets.c: accept_connection > >in the fallback path which does: > > lock_request (); > > thread_data->sock = set_cloexec (accept (listen_sock, NULL, NULL)); > > unlock_request () > > > >Because there is no current connection in this thread this code fails. > > > >However it should be possible to call lock_request without a > >connection, provided that > >thread_model <= NBDKIT_THREAD_MODEL_SERIALIZE_REQUESTS (which it is > >when the fallback path is engaged on Haiku). There was a regression > >caused when I modified to code to use an implicit TLS connection. > > > >Fixes commit 91023f269d4cea56f573a1aa0d880b12052f6e1e. > >--- > > server/locks.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > ACKThanks - I tidied up the commit message a bit when I pushed it. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into KVM guests. http://libguestfs.org/virt-v2v
Reasonably Related Threads
- [PATCH nbdkit] server/locks: Allow lock_request to be called when there is no current conn.
- [PATCH nbdkit] server: Remove useless thread local sockaddr.
- [PATCH nbdkit] server: Fix parameters of lock_request, unlock_request on fallback path.
- [nbdkit PATCH 4/4] sockets: Fix lifetime of thread_data
- [PATCH nbdkit 2/2] server: Disable Nagle's algorithm.