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(a)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