From 6e5ac6ba8e229b5f8963efdce23072cf3b2b6dfc Mon Sep 17 00:00:00 2001 From: Paul Eggleton Date: Mon, 17 Aug 2015 12:12:18 +0100 Subject: bitbake: cooker: further limit inotify watches Unfortunately we were acting on inotify notifications about any files changing within the watched directories, not just the ones we actually care about. In OE the build directory is in BBPATH and hence it gets watched, and we write things like bitbake.lock and bitbake-cookerdaemon.log to that directory, hence effectively notifications were being tripped on every bitbake invocation. To avoid this, record which file/subdirectory we're interested in against each watched directory so we can ignore any events for files/subdirectories we don't care about. Additionally, if we move up to the parent dir, ensure we haven't already seen it before adding a watch on it (we were previously calling watcher.add_watch() on the same directory multiple times before in a typical OE configuration). (Bitbake rev: bc39b8da34c046b629c43fd0a8cac2efbf1c060f) Signed-off-by: Paul Eggleton Signed-off-by: Richard Purdie --- bitbake/lib/bb/cooker.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'bitbake/lib/bb/cooker.py') diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py index 84bf46b9ee..f0f9c66f4e 100644 --- a/bitbake/lib/bb/cooker.py +++ b/bitbake/lib/bb/cooker.py @@ -126,12 +126,14 @@ class BBCooker: self.configwatcher = pyinotify.WatchManager() self.configwatcher.bbseen = [] + self.configwatcher.bbwatchedfiles = [] self.confignotifier = pyinotify.Notifier(self.configwatcher, self.config_notifications) self.watchmask = pyinotify.IN_CLOSE_WRITE | pyinotify.IN_CREATE | pyinotify.IN_DELETE | \ pyinotify.IN_DELETE_SELF | pyinotify.IN_MODIFY | pyinotify.IN_MOVE_SELF | \ pyinotify.IN_MOVED_FROM | pyinotify.IN_MOVED_TO self.watcher = pyinotify.WatchManager() self.watcher.bbseen = [] + self.watcher.bbwatchedfiles = [] self.notifier = pyinotify.Notifier(self.watcher, self.notifications) @@ -185,6 +187,8 @@ class BBCooker: signal.signal(signal.SIGHUP, self.sigterm_exception) def config_notifications(self, event): + if not event.pathname in self.configwatcher.bbwatchedfiles: + return if not event.path in self.inotify_modified_files: self.inotify_modified_files.append(event.path) self.baseconfig_valid = False @@ -198,20 +202,27 @@ class BBCooker: if not watcher: watcher = self.watcher for i in deps: + watcher.bbwatchedfiles.append(i[0]) f = os.path.dirname(i[0]) if f in watcher.bbseen: continue watcher.bbseen.append(f) + watchtarget = None while True: # We try and add watches for files that don't exist but if they did, would influence # the parser. The parent directory of these files may not exist, in which case we need # to watch any parent that does exist for changes. try: watcher.add_watch(f, self.watchmask, quiet=False) + if watchtarget: + watcher.bbwatchedfiles.append(watchtarget) break except pyinotify.WatchManagerError as e: if 'ENOENT' in str(e): + watchtarget = f f = os.path.dirname(f) + if f in watcher.bbseen: + break watcher.bbseen.append(f) continue if 'ENOSPC' in str(e): -- cgit v1.2.3-54-g00ecf