summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2015-08-17 12:12:18 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-08-19 18:05:44 +0100
commit6e5ac6ba8e229b5f8963efdce23072cf3b2b6dfc (patch)
tree6db6b61bd9d4f2983161f7f8fbd4c1be0c38b731
parente0daf784082f27372effa04e987ba7376a26175a (diff)
downloadpoky-6e5ac6ba8e229b5f8963efdce23072cf3b2b6dfc.tar.gz
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 <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/bb/cooker.py11
1 files changed, 11 insertions, 0 deletions
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:
126 126
127 self.configwatcher = pyinotify.WatchManager() 127 self.configwatcher = pyinotify.WatchManager()
128 self.configwatcher.bbseen = [] 128 self.configwatcher.bbseen = []
129 self.configwatcher.bbwatchedfiles = []
129 self.confignotifier = pyinotify.Notifier(self.configwatcher, self.config_notifications) 130 self.confignotifier = pyinotify.Notifier(self.configwatcher, self.config_notifications)
130 self.watchmask = pyinotify.IN_CLOSE_WRITE | pyinotify.IN_CREATE | pyinotify.IN_DELETE | \ 131 self.watchmask = pyinotify.IN_CLOSE_WRITE | pyinotify.IN_CREATE | pyinotify.IN_DELETE | \
131 pyinotify.IN_DELETE_SELF | pyinotify.IN_MODIFY | pyinotify.IN_MOVE_SELF | \ 132 pyinotify.IN_DELETE_SELF | pyinotify.IN_MODIFY | pyinotify.IN_MOVE_SELF | \
132 pyinotify.IN_MOVED_FROM | pyinotify.IN_MOVED_TO 133 pyinotify.IN_MOVED_FROM | pyinotify.IN_MOVED_TO
133 self.watcher = pyinotify.WatchManager() 134 self.watcher = pyinotify.WatchManager()
134 self.watcher.bbseen = [] 135 self.watcher.bbseen = []
136 self.watcher.bbwatchedfiles = []
135 self.notifier = pyinotify.Notifier(self.watcher, self.notifications) 137 self.notifier = pyinotify.Notifier(self.watcher, self.notifications)
136 138
137 139
@@ -185,6 +187,8 @@ class BBCooker:
185 signal.signal(signal.SIGHUP, self.sigterm_exception) 187 signal.signal(signal.SIGHUP, self.sigterm_exception)
186 188
187 def config_notifications(self, event): 189 def config_notifications(self, event):
190 if not event.pathname in self.configwatcher.bbwatchedfiles:
191 return
188 if not event.path in self.inotify_modified_files: 192 if not event.path in self.inotify_modified_files:
189 self.inotify_modified_files.append(event.path) 193 self.inotify_modified_files.append(event.path)
190 self.baseconfig_valid = False 194 self.baseconfig_valid = False
@@ -198,20 +202,27 @@ class BBCooker:
198 if not watcher: 202 if not watcher:
199 watcher = self.watcher 203 watcher = self.watcher
200 for i in deps: 204 for i in deps:
205 watcher.bbwatchedfiles.append(i[0])
201 f = os.path.dirname(i[0]) 206 f = os.path.dirname(i[0])
202 if f in watcher.bbseen: 207 if f in watcher.bbseen:
203 continue 208 continue
204 watcher.bbseen.append(f) 209 watcher.bbseen.append(f)
210 watchtarget = None
205 while True: 211 while True:
206 # We try and add watches for files that don't exist but if they did, would influence 212 # We try and add watches for files that don't exist but if they did, would influence
207 # the parser. The parent directory of these files may not exist, in which case we need 213 # the parser. The parent directory of these files may not exist, in which case we need
208 # to watch any parent that does exist for changes. 214 # to watch any parent that does exist for changes.
209 try: 215 try:
210 watcher.add_watch(f, self.watchmask, quiet=False) 216 watcher.add_watch(f, self.watchmask, quiet=False)
217 if watchtarget:
218 watcher.bbwatchedfiles.append(watchtarget)
211 break 219 break
212 except pyinotify.WatchManagerError as e: 220 except pyinotify.WatchManagerError as e:
213 if 'ENOENT' in str(e): 221 if 'ENOENT' in str(e):
222 watchtarget = f
214 f = os.path.dirname(f) 223 f = os.path.dirname(f)
224 if f in watcher.bbseen:
225 break
215 watcher.bbseen.append(f) 226 watcher.bbseen.append(f)
216 continue 227 continue
217 if 'ENOSPC' in str(e): 228 if 'ENOSPC' in str(e):