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

Eric Blake eblake at redhat.com
Wed Jun 23 13:37:49 UTC 2010


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 at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20100623/7d12550f/attachment-0001.sig>


More information about the libvir-list mailing list