[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Libguestfs] [PATCH libnbd] lib: Remove cookie parameter from completion callbacks.



On 7/30/19 10:36 AM, Richard W.M. Jones wrote:
> As discussed in this thread, the parameter is an invitation to write
> code with race conditions:
> 
> https://www.redhat.com/archives/libguestfs/2019-July/thread.html#00309
> ---

> +++ b/generator/generator
> @@ -1729,7 +1729,7 @@ C<nbd_pread>.";
>      default_call with
>      args = [ BytesPersistOut ("buf", "count"); UInt64 "offset";
>               Closure { cbname="callback";
> -                       cbargs=[Int64 "cookie"; Mutable (Int "error")] };
> +                       cbargs=[Mutable (Int "error")] };

No trailing ; in cbargs=[]...

> @@ -1773,8 +1776,7 @@ documented in C<nbd_pread_structured>.";
>                                 UInt "status";
>                                 Mutable (Int "error"); ]};
>               Closure { cbname="callback";
> -                       cbargs=[Int64 "cookie";
> -                               Mutable (Int "error"); ]};
> +                       cbargs=[Mutable (Int "error"); ]};

...but there is here. Pre-existing, and OCaml tolerates our
inconsistency, but it's probably nicer to uniformly skip the trailing ;.

>               Flags "flags" ];
>      ret = RInt64;
>      permitted_states = [ Connected ];
> @@ -1782,8 +1784,11 @@ documented in C<nbd_pread_structured>.";
>      longdesc = "\
>  Issue a read command to the NBD server.  This returns the
>  unique positive 64 bit cookie for this command, or C<-1> on
> -error.  If this command returns a cookie, then C<callback>
> +error.
> +
> +When the command completes, C<callback>
>  will be invoked as described in L<libnbd(3)/Completion callbacks>.
> +

Do we need wording anywhere (probably in the .pod, so we only state it
once) that mentions that the callback routine is not invoked if
nbd_aio_FOO_callback returns -1?

ACK.

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

Attachment: signature.asc
Description: OpenPGP digital signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]