[Libguestfs] [PATCH libnbd discussion only 3/5] lib: Pass handle to socket recv and send calls.
Richard W.M. Jones
rjones at redhat.com
Mon Jun 3 16:41:50 UTC 2019
On Mon, Jun 03, 2019 at 11:19:15AM -0500, Eric Blake wrote:
> On 6/3/19 10:29 AM, Richard W.M. Jones wrote:
> > Just a simple refactoring in preparation for forthcoming work.
> > ---
> > generator/states-reply.c | 2 +-
> > generator/states.c | 4 ++--
> > lib/crypto.c | 5 +++--
> > lib/internal.h | 6 ++++--
> > lib/socket.c | 5 +++--
> > 5 files changed, 13 insertions(+), 9 deletions(-)
> >
> > diff --git a/generator/states-reply.c b/generator/states-reply.c
> > index 5be3431..f0ef47c 100644
> > --- a/generator/states-reply.c
> > +++ b/generator/states-reply.c
> > @@ -36,7 +36,7 @@
> > h->rbuf = &h->sbuf;
> > h->rlen = sizeof h->sbuf.simple_reply;
> >
> > - r = h->sock->ops->recv (h->sock, h->rbuf, h->rlen);
> > + r = h->sock->ops->recv (h, h->sock, h->rbuf, h->rlen);
>
> Do we need to pass both h and h->sock, or can the caller access h->sock
> through h? (Maybe I should read patch 4 first?)
It would work, but only coincidentally. If we added a different
"upper layer" (other than lib/crypto.c) which worked in a slightly
different way then there wouldn't the relationship between h and
h->sock.
> Otherwise, 1-3 look fine once cleaned up, and can probably be applied
> now even if you are still working on 4-5.
Thanks, I've cleaned up 1 & 2 adding your suggestions and will push
them in a moment.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine. Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/
More information about the Libguestfs
mailing list