On Thu, Oct 27, 2022 at 09:49:52AM +0100, Richard W.M. Jones wrote:
> On Wed, Oct 26, 2022 at 05:18:00PM -0500, Eric Blake wrote:
> > -  if (conn->sockin >= 0)
> > -    closesocket (conn->sockin);
> > -  if (conn->sockout >= 0 && conn->sockin != conn->sockout)
> > -    closesocket (conn->sockout);
> > +  if (conn->sockout >= 0 && how == SHUT_WR) {
> > +    if (conn->sockin == conn->sockout)
> > +      shutdown (conn->sockout, how);
> > +    else
> > +      closesocket (conn->sockout);
> > +    conn->sockout = -1;
> 
> Don't we leak conn->sockin, if how == SHUT_WR && conn->sockin == 
> conn->sockout?

No, because any call with how==SHUT_WR will eventually be followed by
another call with how==SHUT_RDWR, and it is the latter call which
handles closing sockin.

> 
> Rich.
> 
> > +  }
> > +  else {
> > +    if (conn->sockin >= 0)
> > +      closesocket (conn->sockin);
> > +    if (conn->sockout >= 0 && conn->sockin != conn->sockout)
> > +      closesocket (conn->sockout);
> > +  }
> >  }

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
_______________________________________________
Libguestfs mailing list
Libguestfs@redhat.com
https://listman.redhat.com/mailman/listinfo/libguestfs

Reply via email to