CID-701956: list_remove_head_item may return null.

Simplified from while (1) to while that checks sem directly.
This commit is contained in:
Fredrik Holmqvist
2012-07-31 20:51:02 +02:00
parent 66f16cca0a
commit 57e2ce542e
+5 -7
View File
@@ -116,16 +116,14 @@ tq_handle_thread(void *data)
sem = tq->tq_sem; sem = tq->tq_sem;
tq_unlock(tq, cpu_state); tq_unlock(tq, cpu_state);
while (1) { while (acquire_sem(sem) == B_NO_ERROR) {
status_t status = acquire_sem(sem);
if (status < B_OK)
break;
tq_lock(tq, &cpu_state); tq_lock(tq, &cpu_state);
t = list_remove_head_item(&tq->tq_list); t = list_remove_head_item(&tq->tq_list);
tq_unlock(tq, cpu_state);
if (t == NULL)
continue;
pending = t->ta_pending; pending = t->ta_pending;
t->ta_pending = 0; t->ta_pending = 0;
tq_unlock(tq, cpu_state);
t->ta_handler(t->ta_argument, pending); t->ta_handler(t->ta_argument, pending);
} }
@@ -319,7 +317,7 @@ init_taskqueues()
return B_NO_MEMORY; return B_NO_MEMORY;
status = taskqueue_start_threads(&taskqueue_fast, 1, status = taskqueue_start_threads(&taskqueue_fast, 1,
B_REAL_TIME_PRIORITY, "fast taskq"); B_REAL_TIME_PRIORITY, "fast taskq thread");
if (status < B_OK) if (status < B_OK)
goto err_1; goto err_1;
} }