* Block until all currently queued tasks in this taskqueue * have begun execution. Tasks queued during execution of * this function are ignored. */
| 361 | * this function are ignored. |
| 362 | */ |
| 363 | static int |
| 364 | taskqueue_drain_tq_queue(struct taskqueue *queue) |
| 365 | { |
| 366 | #ifdef FSTACK // for dangling-pointer |
| 367 | static |
| 368 | #endif |
| 369 | struct task t_barrier; |
| 370 | |
| 371 | if (STAILQ_EMPTY(&queue->tq_queue)) |
| 372 | return (0); |
| 373 | |
| 374 | /* |
| 375 | * Enqueue our barrier after all current tasks, but with |
| 376 | * the highest priority so that newly queued tasks cannot |
| 377 | * pass it. Because of the high priority, we can not use |
| 378 | * taskqueue_enqueue_locked directly (which drops the lock |
| 379 | * anyway) so just insert it at tail while we have the |
| 380 | * queue lock. |
| 381 | */ |
| 382 | TASK_INIT(&t_barrier, UCHAR_MAX, taskqueue_task_nop_fn, &t_barrier); |
| 383 | STAILQ_INSERT_TAIL(&queue->tq_queue, &t_barrier, ta_link); |
| 384 | queue->tq_hint = &t_barrier; |
| 385 | t_barrier.ta_pending = 1; |
| 386 | |
| 387 | /* |
| 388 | * Once the barrier has executed, all previously queued tasks |
| 389 | * have completed or are currently executing. |
| 390 | */ |
| 391 | while (t_barrier.ta_pending != 0) |
| 392 | TQ_SLEEP(queue, &t_barrier, "tq_qdrain"); |
| 393 | return (1); |
| 394 | } |
| 395 | |
| 396 | /* |
| 397 | * Block until all currently executing tasks for this taskqueue |
no test coverage detected