aboutsummaryrefslogtreecommitdiffstats
path: root/syz-verifier/exectask.go
diff options
context:
space:
mode:
authorTaras Madan <tarasmadan@google.com>2022-03-30 11:50:14 +0200
committerGitHub <noreply@github.com>2022-03-30 11:50:14 +0200
commit42718dd659525414aa0bf2794688ac94a32f7764 (patch)
tree669d7e5f67dc6203fd4f4f3b26a538d99fd6c877 /syz-verifier/exectask.go
parent6bdac76629d4d80501671c0c312d6b81411481e7 (diff)
syz-verifier/exectask.go: add tests
Diffstat (limited to 'syz-verifier/exectask.go')
-rw-r--r--syz-verifier/exectask.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/syz-verifier/exectask.go b/syz-verifier/exectask.go
index 052469ed7..db947cbcd 100644
--- a/syz-verifier/exectask.go
+++ b/syz-verifier/exectask.go
@@ -66,6 +66,12 @@ func MakeExecTask(prog *prog.Prog) *ExecTask {
return task
}
+func ExecTasksQueued() int {
+ ChanMapMutex.Lock()
+ defer ChanMapMutex.Unlock()
+ return len(TaskIDToExecResultChan)
+}
+
func DeleteExecTask(task *ExecTask) {
ChanMapMutex.Lock()
defer ChanMapMutex.Unlock()
@@ -88,22 +94,28 @@ func MakeExecTaskQueue() *ExecTaskQueue {
// ExecTaskQueue respects the pq.priority. Internally it is a thread-safe PQ.
type ExecTaskQueue struct {
pq ExecTaskPriorityQueue
+ mu sync.Mutex
}
// PopTask return false if no tasks are available.
func (q *ExecTaskQueue) PopTask() (*ExecTask, bool) {
+ q.mu.Lock()
+ defer q.mu.Unlock()
if q.pq.Len() == 0 {
return nil, false
}
-
return heap.Pop(&q.pq).(*ExecTask), true
}
func (q *ExecTaskQueue) PushTask(task *ExecTask) {
+ q.mu.Lock()
+ defer q.mu.Unlock()
heap.Push(&q.pq, task)
}
func (q *ExecTaskQueue) Len() int {
+ q.mu.Lock()
+ defer q.mu.Unlock()
return q.pq.Len()
}