ui/vnc-jobs: narrow taking the queue lock
It's not needed unless manipulating the queue. Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Marc-André Lureau committed
Mar 13, 2026 at 23:43 UTC
ed4c1c716dc89ca4f4d950683ee7d6c6c33161f0
1 file changed
+11
-6
ui/vnc-jobs.c
+11
-6
@@ -83,26 +83,26 @@ VncJob *vnc_job_new(VncState *vs)
83
84
assert(vs->magic == VNC_MAGIC);
85
job->vs = vs;
86
- vnc_lock_queue(queue);
86
QLIST_INIT(&job->rectangles);
88
- vnc_unlock_queue(queue);
87
return job;
88
}
89
90
+/*
91
+ * Do not call this after pushing the job.
92
+ */
93
int vnc_job_add_rect(VncJob *job, int x, int y, int w, int h)
94
{
95
VncRectEntry *entry = g_new0(VncRectEntry, 1);
96
97
trace_vnc_job_add_rect(job->vs, job, x, y, w, h);
98
+ assert(!QTAILQ_IN_USE(job, next));
99
100
entry->rect.x = x;
101
entry->rect.y = y;
102
entry->rect.w = w;
103
entry->rect.h = h;
104
103
- vnc_lock_queue(queue);
105
QLIST_INSERT_HEAD(&job->rectangles, entry, next);
105
- vnc_unlock_queue(queue);
106
return 1;
107
}
108
@@ -120,16 +120,21 @@ static void vnc_job_free(VncJob *job)
120
g_free(job);
121
}
122
123
+/*
124
+ * Push a job onto the queue. Ownership of the job is transferred.
125
+ */
126
void vnc_job_push(VncJob *job)
127
{
125
- vnc_lock_queue(queue);
128
+ assert(!QTAILQ_IN_USE(job, next));
129
+
130
if (QLIST_EMPTY(&job->rectangles)) {
131
vnc_job_free(job);
132
} else {
133
+ vnc_lock_queue(queue);
134
QTAILQ_INSERT_TAIL(&queue->jobs, job, next);
135
qemu_cond_broadcast(&queue->cond);
136
+ vnc_unlock_queue(queue);
137
}
132
- vnc_unlock_queue(queue);
138
}
139
140
static bool vnc_has_job_locked(VncState *vs)