<br><tt><font size=2>libvir-list-bounces@redhat.com wrote on 10/22/2010
02:24:38 PM:<br>
<br>
<br>
> On 10/22/2010 05:19 AM, Stefan Berger wrote:<br>
> > Using automated replacement with sed and editing I have now replaced
all<br>
> > occurrences of close() with VIR_(FORCE_)CLOSE() except for one,
of<br>
> > course. Some replacements were straight forward, others I needed
to pay<br>
> > attention. I hope I payed attention in all the right places...
Please<br>
> > have a look. This should have at least solved one more double-close<br>
> > error.<br>
> ><br>
> > Signed-off-by: Stefan Berger<stefanb@us.ibm.com><br>
> ><br>
> > ---<br>
> > daemon/libvirtd.c
| 46 ++++++---------<br>
> <br>
> Continuing on (looks like I'll be replying quite a few times today)...<br>
> <br>
> > @@ -127,7 +128,7 @@ static int lxcContainerExecInit(virDomai<br>
> > static int lxcContainerSetStdio(int control, int ttyfd)<br>
> > {<br>
> > int rc = -1;<br>
> > - int open_max, i;<br>
> > + int open_max, i, tpmfd;<br>
> ><br>
> > if (setsid()< 0) {<br>
> > virReportSystemError(errno,
"%s",<br>
> > @@ -145,8 +146,10 @@ static int lxcContainerSetStdio(int cont<br>
> > * close all FDs before executing the
container */<br>
> > open_max = sysconf (_SC_OPEN_MAX);<br>
> > for (i = 0; i< open_max; i++)<br>
> > - if (i != ttyfd&& i
!= control)<br>
> > - close(i);<br>
> > + if (i != ttyfd&& i
!= control) {<br>
> > + tpmfd = i;<br>
> > + VIR_FORCE_CLOSE(tpmfd);<br>
> <br>
> Yeah, I guess you do have to introduce a temporary rather than <br>
> clobbering your iterator.<br>
> <br>
> s/tpmfd/tmpfd/, and perhaps reduce it's scope to just the for loop
or if <br>
> statement where it is needed.</font></tt>
<br>
<br><tt><font size=2>ha, what a typo... making it a local variable.</font></tt>
<br><tt><font size=2><br>
<br>
> > - close(logfd);<br>
> > + if (rc != 0)<br>
> > + VIR_FORCE_CLOSE(priv->monitor);<br>
> > + VIR_FORCE_CLOSE(parentTty);<br>
> > + VIR_FORCE_CLOSE(logfd);<br>
> <br>
> logfd might be one where we want to hoist a normal VIR_CLOSE and check
<br>
> for errors.</font></tt>
<br>
<br><tt><font size=2>Ok, so I call the virReportSystemError() on this now.</font></tt>
<br>
<br><tt><font size=2> Stefan</font></tt>
<br>