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

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



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

Attachment: signature.asc
Description: OpenPGP digital signature


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