using gethostid() function provide by glibc trying to open twice a file which don't exist. strace output concerning this function. open("/etc/hostid", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory) open("/etc/hostid", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
Created attachment 1158 [details] sample for reproduct hostid.c is an example for reproduct.
Created attachment 1159 [details] patch for fedora core 3 SRPMS glibc-2.3.3-74.src.rpm patch for fedora core 3 SRPMS glibc-2.3.3-74.src.rpm
Created attachment 1160 [details] patch for generic GNU glibc 2.3 patch for generic GNU glibc 2.3
This exist also on glibc 2.4 and the patch is the same. ( use stat )
I've changed this is CVS. The patch isn't OK. There is no need for the stat because a) it's not really much faster than the open and b) if somebody uses gethostid there better be such a file. The real problem was that the patch introducing the OLD_HOSTIDFILE macro contained abug. This is now fixed.
Thanks for this ;) I'm agree with you about open and stat and their performance on local filesystem. But It seems thant it's not the case over Network filesystem or Virtual filesystem. Sure isn't a good idea to have /etc/ over VFS or NFS, but in this case it seems than using 'open' have mores 'impact' than using only stat. Performance be better and we don't have problem with concurent remote access. But in fact is it true or it's just my feelings ? Julien