On Tue, Aug 13, 2019 at 10:56:45AM -0500, Eric Blake wrote:
> +++ b/ocaml/examples/asynch_copy.ml
> @@ -48,7 +48,7 @@ let asynch_copy src dst =
> if !soff < size && NBD.aio_in_flight src < max_reads_in_flight
then (
> let bs = min bs (size -^ !soff) in
> let buf = NBD.Buffer.alloc (Int64.to_int bs) in
> - ignore (NBD.aio_pread_callback src buf !soff
> + ignore (NBD.aio_pread src buf !soff
> ~completion:(read_completed buf !soff));
Pre-existing; but is the indentation off here? (I would have guessed two
fewer spaces, so that ~completion starts just after the ( above)
I think this is a bug in tuareg-mode probably, as in that's the
indentation I get when I hit <tab>, but it's also kind of wrong.
~completion is a labeled argument of NBD.aio_pread, and with normal
arguments tuareg will line them up. So it ought to appear directly
under "src" on the preceding line.
ACK with typo fix.
OK I'm going to push this series with all the fixes you suggested.
After that, we still haven't fixed the original problem of freeing
Python persistent buffers, nor decided whether or not to get rid of
valid_flag. To do that I therefore intend to write a patch series
which adds a third parameter (free_callback) as you suggested.
Although I think actually passing 3 parameters per callback is
something of a pain, even for C users who might expect some pain. I
was thinking we should put them in a struct and pass the struct (not a
pointer), so it'd be something like:
#include <libnbd.h> contains:
struct nbd_completion_callback {
int (*callback) (void *user_data, int *error);
void *user_data;
void (*free_user_data) (void *user_data);
};
//...
struct nbd_completion_callback {
.callback = my_callback, .user_data = my_data, .free_user_data = free
} completion_callback;
nbd_aio_pread (h, buf, count, offset, completion_callback, flags);
Apparently a compound literal would work too although I didn't try it
yet:
nbd_aio_pread (h, buf, count, offset, (struct nbd_completion_callback) { .callback =
my_callback, .user_data = my_data, .free_user_data = free }, flags);
Thanks,
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW