我有一个小的Java程序,它每秒循环调用InetAddress.getByName(“ example.com”)。当我使用'strace -f'在CentOS 6.4盒子上运行它时,我看到/etc/resolv.conf已打开并读取一次:
$ grep /etc/resolv.conf strace.out
[pid 24810] open("/etc/resolv.conf", O_RDONLY) = 6
当我在Debian 7上运行它时,我看到/etc/resolv.conf被重复打开或stat()':
$ grep /etc/resolv.conf strace.out
[pid 41821] open("/etc/resolv.conf", O_RDONLY) = 10
[pid 41821] stat("/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=92, ...}) = 0
[pid 41821] open("/etc/resolv.conf", O_RDONLY) = 10
[pid 41821] stat("/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=92, ...}) = 0
[pid 41821] stat("/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=92, ...}) = 0
两个系统都配置了/etc/nsswitch.conf
主机:文件dns
这两个系统都没有运行名称缓存守护程序。
我在两台计算机上都使用了相同版本的Oracle HotSot Java JVM,以排除Java的任何差异。
CentOS 6.4盒已安装glibc 2.12。Debian 7盒子安装了glibc 2.13。
是什么导致两个操作系统在打开和读取/etc/resolv.conf方面的不同行为?