summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2009-07-26 14:33:39 +0000
committerNarayan Desai <desai@mcs.anl.gov>2009-07-26 14:33:39 +0000
commitc56ea4ee3fa882b74fcffc2680d79f3e442382e8 (patch)
tree447cbd66e70ffca1eede88d8698e4727c4fbc80e
parentdfbe98b1178c1283b894dc81187fb91aab178d68 (diff)
downloadbcfg2-c56ea4ee3fa882b74fcffc2680d79f3e442382e8.tar.gz
bcfg2-c56ea4ee3fa882b74fcffc2680d79f3e442382e8.tar.bz2
bcfg2-c56ea4ee3fa882b74fcffc2680d79f3e442382e8.zip
Gamin: aggressively drain gamin events from the gamin lib interface. (Patch from Michael McCallister)
Gamin doesn't do sufficient checking on the fd between the client and gam_server, so it can end up in a deadlock. This patch insures that the fd has been drained on the client read side before attempting to write to it. These events are buffered in the Gamin file interface until the Core extracts and processes them. (Detailed explanation from Mike as well) git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5386 ce84e21b-d406-0410-9b95-82705330c041
-rw-r--r--src/lib/Server/FileMonitor.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/lib/Server/FileMonitor.py b/src/lib/Server/FileMonitor.py
index eed31df39..046bdb4aa 100644
--- a/src/lib/Server/FileMonitor.py
+++ b/src/lib/Server/FileMonitor.py
@@ -266,6 +266,11 @@ try:
handle = self.counter
self.counter += 1
mode = os.stat(path)[stat.ST_MODE]
+
+ # flush queued gamin events
+ while self.mon.event_pending():
+ self.mon.handle_one_event()
+
if stat.S_ISDIR(mode):
self.mon.watch_directory(path, self.queue, handle)
else:
@@ -274,10 +279,11 @@ try:
return handle
def pending(self):
- return self.mon.event_pending()
+ return len(self.events) > 0 or self.mon.event_pending()
def get_event(self):
- self.mon.handle_one_event()
+ if self.mon.event_pending():
+ self.mon.handle_one_event()
return self.events.pop()
available['gamin'] = Gamin