From c56ea4ee3fa882b74fcffc2680d79f3e442382e8 Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Sun, 26 Jul 2009 14:33:39 +0000 Subject: 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 --- src/lib/Server/FileMonitor.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/lib') 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 -- cgit v1.2.3-1-g7c22