[Libguestfs] [nbdkit PATCH 3/6] connections: Add read/write lock over client I/O

Eric Blake eblake at redhat.com
Fri Nov 17 18:28:09 UTC 2017


On 11/17/2017 02:59 AM, Richard W.M. Jones wrote:
> On Thu, Nov 16, 2017 at 09:26:54PM -0600, Eric Blake wrote:
>> In preparation for parallel processing, we need to be sure that
>> two threads belonging to the same connection cannot interleave
>> their I/O except at message boundaries.  Add a mutex around
>> all reads and writes that must occur as a group (for now, there
>> is no contention for either mutex).
>>
>> Signed-off-by: Eric Blake <eblake at redhat.com>
>> ---
>>  src/connections.c | 27 +++++++++++++++++++++++++--
>>  1 file changed, 25 insertions(+), 2 deletions(-)
>>

> 
> There's nothing wrong with this patch, but it might be easier to use
> an attribute((cleanup)) handler to deal with the unlocking.  See these
> links for how we do it in libguestfs:

Oh cool! Yes, that looks nicer.  Although the diffstat for doing so is
larger, because it requires adding to new sub-function {} scopes and
reindenting (we have two different locks in play here).

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20171117/856a97bd/attachment.sig>


More information about the Libguestfs mailing list