Re: [PATCH 1/2] cgroup: Change virCgroupRemove to remove all child groups at first

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

 



On 06/23/2010 05:51 AM, Ryota Ozaki wrote:
>> Technically, any loop over readdir must first set errno to 0, then call
>> readdir, and if it is NULL, check if errno is still 0.  Otherwise, you
>> can miss subtle readdir failures.
> 
> Oh, right. So revised version will be like this:
> 
> for (;;) {
>   errno = 0;
>   ent = readdir(grpdir);
>   if (ent == NULL) {
>     if (errno)
>       VIR_ERROR(_("Failed to readdir for %s (%d)")_, grppath, errno);
>     break;
>   }
>     ...
> }
> 
> If I miss something, please let me know.

Yes, that is a correct usage pattern for readdir.

Also, I missed it the first time, but you are leaking fd's - you called
grpdir=opendir(grppath), but never called closedir(grpdir).

-- 
Eric Blake   eblake@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]