From 0ce5b22a45d675de6969f3f5e5d4565be0a2d2d1 Mon Sep 17 00:00:00 2001 From: Ricky Zhou Date: Sat, 11 Jul 2009 01:57:52 -0400 Subject: [PATCH/puppet] Fix #1963 - Failing to read /proc/mounts for selinux kills file downloads This works around a linux kernel bug that causes a select() on /proc/mounts to hang. --- lib/puppet/util/selinux.rb | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/puppet/util/selinux.rb b/lib/puppet/util/selinux.rb index cd3b2ac..dc5daec 100644 --- a/lib/puppet/util/selinux.rb +++ b/lib/puppet/util/selinux.rb @@ -152,9 +152,15 @@ module Puppet::Util::SELinux # Internal helper function to read and parse /proc/mounts def read_mounts + mounts = "" begin - mountfh = File.open("/proc/mounts", NONBLOCK) - mounts = mountfh.read + mountfh = File.open("/proc/mounts") + # We use read_nonblock() in a loop rather than read() to work-around + # a linux kernel bug. See ticket #1963 for details. + while true + mounts += mountfh.read_nonblock(1024) + end + rescue EOFError mountfh.close rescue return nil -- 1.6.3.3