diff options
| author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-08-09 12:54:34 +0100 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-08-13 09:28:14 +0100 |
| commit | 019f518287bb00f7e7121289b4859661af201d89 (patch) | |
| tree | bd3da21f0f02251133751d700b92d3517cb15778 /bitbake | |
| parent | 0cb62f8ca7de95801aa6e47a4a37aedc6e311bd6 (diff) | |
| download | poky-019f518287bb00f7e7121289b4859661af201d89.tar.gz | |
bitbake: cooker: Ensure we handle inotify before running the next command
The inotify watch events are handled "at idle" which could in theory mean
a command could run before any preceeding inotify events have been processed.
This leads to a theoretical race window where those events may have a
signficicant effect on the command.
Add a mechanism to allow us to ensure all pending events are processed before
running commands.
(Bitbake rev: bf76cd7e5881adf264b8ba64e27a5b6ca9df4fde)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
| -rw-r--r-- | bitbake/lib/bb/command.py | 2 | ||||
| -rw-r--r-- | bitbake/lib/bb/cooker.py | 17 |
2 files changed, 12 insertions, 7 deletions
diff --git a/bitbake/lib/bb/command.py b/bitbake/lib/bb/command.py index c44c7a6a5e..a9232455cc 100644 --- a/bitbake/lib/bb/command.py +++ b/bitbake/lib/bb/command.py | |||
| @@ -78,6 +78,7 @@ class Command: | |||
| 78 | if not hasattr(command_method, 'readonly') or False == getattr(command_method, 'readonly'): | 78 | if not hasattr(command_method, 'readonly') or False == getattr(command_method, 'readonly'): |
| 79 | return None, "Not able to execute not readonly commands in readonly mode" | 79 | return None, "Not able to execute not readonly commands in readonly mode" |
| 80 | try: | 80 | try: |
| 81 | self.cooker.process_inotify_updates() | ||
| 81 | if getattr(command_method, 'needconfig', False): | 82 | if getattr(command_method, 'needconfig', False): |
| 82 | self.cooker.updateCacheSync() | 83 | self.cooker.updateCacheSync() |
| 83 | result = command_method(self, commandline) | 84 | result = command_method(self, commandline) |
| @@ -98,6 +99,7 @@ class Command: | |||
| 98 | 99 | ||
| 99 | def runAsyncCommand(self): | 100 | def runAsyncCommand(self): |
| 100 | try: | 101 | try: |
| 102 | self.cooker.process_inotify_updates() | ||
| 101 | if self.cooker.state in (bb.cooker.state.error, bb.cooker.state.shutdown, bb.cooker.state.forceshutdown): | 103 | if self.cooker.state in (bb.cooker.state.error, bb.cooker.state.shutdown, bb.cooker.state.forceshutdown): |
| 102 | # updateCache will trigger a shutdown of the parser | 104 | # updateCache will trigger a shutdown of the parser |
| 103 | # and then raise BBHandledException triggering an exit | 105 | # and then raise BBHandledException triggering an exit |
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py index ea4df266f5..77b7f3dde1 100644 --- a/bitbake/lib/bb/cooker.py +++ b/bitbake/lib/bb/cooker.py | |||
| @@ -205,15 +205,11 @@ class BBCooker: | |||
| 205 | 205 | ||
| 206 | self.inotify_modified_files = [] | 206 | self.inotify_modified_files = [] |
| 207 | 207 | ||
| 208 | def _process_inotify_updates(server, notifier_list, abort): | 208 | def _process_inotify_updates(server, cooker, abort): |
| 209 | for n in notifier_list: | 209 | cooker.process_inotify_updates() |
| 210 | if n.check_events(timeout=0): | ||
| 211 | # read notified events and enqeue them | ||
| 212 | n.read_events() | ||
| 213 | n.process_events() | ||
| 214 | return 1.0 | 210 | return 1.0 |
| 215 | 211 | ||
| 216 | self.configuration.server_register_idlecallback(_process_inotify_updates, [self.confignotifier, self.notifier]) | 212 | self.configuration.server_register_idlecallback(_process_inotify_updates, self) |
| 217 | 213 | ||
| 218 | # TOSTOP must not be set or our children will hang when they output | 214 | # TOSTOP must not be set or our children will hang when they output |
| 219 | try: | 215 | try: |
| @@ -241,6 +237,13 @@ class BBCooker: | |||
| 241 | os.write(readypipe, b"ready") | 237 | os.write(readypipe, b"ready") |
| 242 | os.close(readypipe) | 238 | os.close(readypipe) |
| 243 | 239 | ||
| 240 | def process_inotify_updates(self): | ||
| 241 | for n in [self.confignotifier, self.notifier]: | ||
| 242 | if n.check_events(timeout=0): | ||
| 243 | # read notified events and enqeue them | ||
| 244 | n.read_events() | ||
| 245 | n.process_events() | ||
| 246 | |||
| 244 | def config_notifications(self, event): | 247 | def config_notifications(self, event): |
| 245 | if event.maskname == "IN_Q_OVERFLOW": | 248 | if event.maskname == "IN_Q_OVERFLOW": |
| 246 | bb.warn("inotify event queue overflowed, invalidating caches.") | 249 | bb.warn("inotify event queue overflowed, invalidating caches.") |
