From 764739f2cb6d0dddc2ea25a3cdb837aac252fd73 Mon Sep 17 00:00:00 2001 From: Joshua Ogunyinka Date: Tue, 20 Aug 2019 13:14:39 +0100 Subject: [PATCH 1/2] Fixed blocker bug --- Interlace/lib/core/input.py | 10 ++++++---- Interlace/lib/threader.py | 13 +++++++------ foo.test | 4 ++++ 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Interlace/lib/core/input.py b/Interlace/lib/core/input.py index 21b36dd..439dd33 100644 --- a/Interlace/lib/core/input.py +++ b/Interlace/lib/core/input.py @@ -112,9 +112,11 @@ class InputHelper(object): if task_name == new_task_name: return task_block # otherwise pre-process all the commands in this new `new_task_name` block - for task in InputHelper._pre_process_commands(command_list, new_task_name, False): + tasks = InputHelper._pre_process_commands(command_list, new_task_name, False) + for task in tasks: task_block.append(task) - sibling = task + if len(tasks) > 0: + sibling = tasks[-1] continue else: # if a blocker is encountered, all commands following the blocker must wait until the last @@ -126,10 +128,10 @@ class InputHelper(object): # if we're in the global scope and there was a previous _blocker_ encountered, we wait for the last # child of the block if is_global_task and global_task: - task.wait_for(global_task.get_lock()) + task.wait_for(task_block) # all but the first command in a block scope wait for its predecessor elif sibling and not is_global_task: - task.wait_for(sibling.get_lock()) + task.wait_for([sibling]) task_block.append(task) sibling = task return task_block diff --git a/Interlace/lib/threader.py b/Interlace/lib/threader.py index 26d11df..8129a48 100644 --- a/Interlace/lib/threader.py +++ b/Interlace/lib/threader.py @@ -9,7 +9,7 @@ class Task(object): def __init__(self, command): self.task = command self.self_lock = None - self.sibling_lock = None + self.sibling_locks = [] def __cmp__(self, other): return self.name() == other.name() @@ -20,21 +20,22 @@ class Task(object): def clone(self): new_task = Task(self.task) new_task.self_lock = self.self_lock - new_task.sibling_lock = self.sibling_lock + new_task.sibling_locks = self.sibling_locks return new_task def replace(self, old, new): self.task = self.task.replace(old, new) def run(self, t=False): - if self.sibling_lock: - self.sibling_lock.wait() + for lock in self.sibling_locks: + lock.wait() self._run_task(t) if self.self_lock: self.self_lock.set() - def wait_for(self, _lock): - self.sibling_lock = _lock + def wait_for(self, siblings): + for sibling in siblings: + self.sibling_locks.append(sibling.get_lock()) def name(self): return self.task diff --git a/foo.test b/foo.test index 441c494..61db40f 100644 --- a/foo.test +++ b/foo.test @@ -13,4 +13,8 @@ echo _target_/b/ echo _target_/re/ _block:file_ _blocker_ +ping 127.0.0.1 -n 10 > nul +ping 127.0.0.1 -n 10 > nul && echo "sleepy" +ping 127.0.0.1 -n 5 > nul && echo "test1" +_blocker_ echo "Done" From 377a9482806149207c305f2f7e96ff9ba36b1088 Mon Sep 17 00:00:00 2001 From: Joshua Ogunyinka Date: Tue, 20 Aug 2019 13:26:33 +0100 Subject: [PATCH 2/2] Delete foo.test --- foo.test | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 foo.test diff --git a/foo.test b/foo.test deleted file mode 100644 index 61db40f..0000000 --- a/foo.test +++ /dev/null @@ -1,20 +0,0 @@ -echo hello -_block:file-creation_ -echo _target_ -echo _target_/a/ -echo _target_/output/scans -_block:file-creation_ -echo "Doing this" -_blocker_ -echo "Proceeding" -_block:file_ -echo _target_/out/scans -echo _target_/b/ -echo _target_/re/ -_block:file_ -_blocker_ -ping 127.0.0.1 -n 10 > nul -ping 127.0.0.1 -n 10 > nul && echo "sleepy" -ping 127.0.0.1 -n 5 > nul && echo "test1" -_blocker_ -echo "Done"